Windows Forms Strange Behavior

  • Thread starter Thread starter Doug Holland
  • Start date Start date
D

Doug Holland

I have a Windows Forms application with an annoying bug in it that I cannot
seem to track down.

When an operation is performed by the user then in some cases the
application ceases to be the active Window. This is still the case if I use
the BackgroundWorker component to perform the operation asynchronously.

Any thoughts?

I've developed a bunch of Windows Forms applications over the years and have
never seen this behavior before.

Thanks,

Doug
 
When an operation is performed by the user then in some cases the
application ceases to be the active Window. This is still the case if I use
the BackgroundWorker component to perform the operation asynchronously.
Any thoughts?

1. Does the operation in question always cause the phenomenon, or only
sometimes? I know you said 'in some cases', but could you be more specific?
Do other operations also always/sometimes cause the phenomenon?

2. What window becomes the active window? Is it predictable and
reproducible?

3. Does the operation launch any processes? Does it interact with any
other processes? In either case, the other process may take focus.

4. How does the user indicate that he wants to perform the operation? Some
keystrokes are handled by windows and some of these change focus (eg Alt+Tab).
 
Actually the cause of the bug appears to be the MessageBoxOptions was set to
DefaultDesktopOnly.

Removing the MessageBox code that asked the user if they really wanted to
remove the entities solved the problem.

When I said "some cases" it actually turned out to be everytime I prompted
the user for confirmation. I've now corrected the code to use a static
factory method to create the appropriate MessageBoxOptions. The static
factory code is based upon the C# code in the MSDN documentation for CA1300
(static code analysis warning).

Thanks,

Doug
 
Back
Top