Control Box does not close form
-
I have run into an issue in C# / .Net where the control box will not close the form when the user clicks on it. When my app initially runs, it works fine, but after a while it does nothing when clicked on. I have multiple apps that act in this manner. Has anyone else run into this? Is there a fix for it? dpb Darryl Borden Principal IT Analyst darryl.borden@elpaso.com
-
I have run into an issue in C# / .Net where the control box will not close the form when the user clicks on it. When my app initially runs, it works fine, but after a while it does nothing when clicked on. I have multiple apps that act in this manner. Has anyone else run into this? Is there a fix for it? dpb Darryl Borden Principal IT Analyst darryl.borden@elpaso.com
This commonly happens when a multi-threaded app has different threads setting properties on the controls that were created in a different thread, or when unhandled exceptions occur during instantiation of the main application form (the form used in the call to
Application.Run
). First go through and make sure that you're handling all exceptions that could occur during instantiation of your child controls and that no worker threads are setting properties (and many times even getting properties) or calling methods on the controls from those threads (seeControl.InvokeRequired
andControl.Invoke
in the .NET Framework SDK for more information). A work-around is to useApplication.Quit
for your File->Exit (or whatever) menu instead of just callingClose
on your form.Microsoft MVP, Visual C# My Articles