Windows Forms Strange Behavior

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
 
A

AMercer

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).
 
D

Doug Holland

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top