I've "inherited" a legacy C#/C++ program that I have to debug. The current problem is that the .exe won't stop after I close the program, i.e. it still shows up in Task Manager.
This is a problem, because it won't let me restart the program, because only one instance can run. Often killing the process doesn't work; I'm forced to reboot.
I was under the impression that when the main program stopped, all the child threads were also supposed to stop, but I may be wrong.
Q: What would cause a .exe to not stop?
Child threads will not stop automatically unless they have been specifically set as background threads (i.e., with thread.IsBackground = true
).
Edit: It is also possible that the main thread isn't terminating when the form is closed (i.e., there's other code that is set to run after close that isn't completing).
I find it useful to attach to the running process with the debugger and press the pause button. After that I would inspect the Threads window and see what the stack trace is doing for each of the executing threads. The threads window is hidden by default. Here is more information about how to show it and use it:
http://msdn.microsoft.com/en-us/library/w15yf86f.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With