Process continues to run after Application.Exit()

When the user clicks on my Exit menu command I call Close() followed by Application.Exit(). The GUI goes away as expected but the process is still listed in Task Manager. What do I need to do to really terminate the process




Answer this question

Process continues to run after Application.Exit()

  • nathandyck

    You might leave unmanaged resources allocated if you use Environment.Exit()

    I see now that Application.Exit() should inform all messageloops to terminate. I did not see that when I made a test application for multi-threading. Maybe it was because I was only debugging it.



  • m_r

    Do you have multiple calls to Application.Run() or other threads running

    You might need to abort running threads and call Application.Exit() for every Applicat ion.Run()



  • Pr0fess0rX

    Do you have any non background threads running

    When creating a thread that you don’t want to manually have to clean up when the app exits, it is a good idea to set it’s IsBackground property to true so that it will die along with the parent.



  • SPAWN_UK

    Well, I did not explicitly start any additional threads, but it's obvious that the WebBrowser control uses background threads to get its work done. So, I don't really know what other threads might be running. And VS 2005 C# *Express* does not seem to have a facility for displaying the threads that belong to the process being debugged.



  • Andy Eastwell

    Another suggestion given to me was Environment.Exit() with the caveat that is more brute force, less graceful. Any problems I should be aware of with that approach

  • Process continues to run after Application.Exit()