Windows Develop Bookmark and Share   
 index > Windows Forms General > WinForms app not closing right
 

WinForms app not closing right

Hi all,

i have winforms app, with Unhandledexception and Threadexception events.

When I close the app, click in X in form, the application dissapears, not visible, but I can see the process in taskmgr.

I check that if there are Unhandledexception, show the error and no process in taskmgr.

any suggestions and comments ??


thanks in advanced

Alhambra Eidos Development  Wednesday, September 30, 2009 9:33 PM
Use the debugger. Debug + Windows + Threads. Don't get confused by the ones started by the CLR. Use Debug + Break All and check what code is running and keeping the process alive.

Hans Passant.
nobugz  Thursday, October 01, 2009 11:28 AM
Beware threads. They'll keep running and keep the process alive unless you set their IsBackground property to true. Of course, you'll want to make sure they shut down cleanly before you let the UI disappear.

Hans Passant.
nobugz  Wednesday, September 30, 2009 10:52 PM
any sample code ??

I think no threads running, but how can I detect if any threads is running ???

Thanks !!!
Alhambra Eidos Development  Thursday, October 01, 2009 11:01 AM
Try with code like..

Environment.Exit(0) while closing the form
Ganapatisb  Thursday, October 01, 2009 11:11 AM
Use the debugger. Debug + Windows + Threads. Don't get confused by the ones started by the CLR. Use Debug + Break All and check what code is running and keeping the process alive.

Hans Passant.
nobugz  Thursday, October 01, 2009 11:28 AM
Thanks mister,

Using Debug + Windows + Threads, and Debug + Break All , it appears severals threads !!! but I dont know how those threads starting... in my forms there is a BackgroundWorker, but I dont start threads (using Thread.Start), perhaps any component inits the threads...

how can I know what component or object starts those threads ??? any helper tool for collect this information ??

Thanks.
Alhambra Eidos Development  Friday, October 02, 2009 6:16 AM
Don't get confused by the ones started by the CLR.

Hans Passant.
nobugz  Friday, October 02, 2009 7:45 AM

Hi Alhambra,

You can use the Threads window to monitor the threads. You can press Ctrl + Alt + H to show it when debugging.

Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, October 02, 2009 9:27 AM

You can use google to search for other answers

Custom Search

More Threads

• Scroll a listbox using mousewheel no matter focus
• Drag & Drop, EnableAutoDragDrop
• System.ServiceProcess.ServiceInstaller Account
• multiple comboboxes selecteditem problem
• Calculate size of listview based on items in it
• Double Buffering - But Which Method?
• Dynamic forms - generated at runtime from xml
• MaxLength of a property in PropertyGrid to 25 characters
• Complex dividing interface
• printing in order