Restarting windows form application
i have a windows application C#4.0 with multithreadings problem is when i close the application ,the process stays on, no matter what i do so i have to do this:
environment.exit(1);
or the process wouldnt close,
problem is if i executed environment开发者_如何转开发.exit(1) then application.restart() wouldn't work then.
any idea how to kill the process and then restart ?
Use the debugger. After you closed your main window, use Debug + Break All. Debug + Windows + Threads. Look at the call stack of the threads you see listed there to find the one that is preventing the program from terminating.
Make sure to make all your worker threads run in the background (set IsBackground
to true before starting them). Background threads don't prevent the process from exiting.
threads that your application creates must be terminated before exiting the application otherwise CPU and/or memory will be consumed by the hanging threads
You can Exit application completely by typing this:
Application.Exit();
For Restarting Application Completely:
Application.Restart();
精彩评论