Checking for Stray modal windows - Performance

Apr 22, 2010 at 10:15 PM

A question for the group.

I am currently checking for any open modal windows in an application.

 

                    if (DlxWrapper.window.ModalWindows().Count > 0 || DlxWrapper.window.MessageBox("*") != null)
                    {
                        DlxWrapper.application.Kill();
                        connectToPortUserPassWarehouseClientMoca(host, port, user, pass, warehouseId, executable, mocaType);
                    }

This is a very expensive action in regards to time and i understand why.
Can anyone think of a better way to check for an unexpected modal window (dialog/exception/whatever) in a way that doesn't involve enumerating over all the controls in a window?

Thanks :)

 

Coordinator
May 18, 2010 at 4:54 AM

You do not have to enumerate over all the controls in a window. You can use the Desktop class and get all the windows and then get all the modal-windows in it. Lesser number of windows you have open on your desktop the faster this would beb.