Program not closing.

chen_tso

New member
Joined
Jul 12, 2007
Messages
2
Programming Experience
Beginner
Hi,

I have a program that doesn't seem to shut down after closing the window with the close button. I checked to see if the main form's dispose is called and it does seem to be called. How would I go about debugging what's causing it not to close?

Please help.

Thanks.

Peter.
 
A common cause is that you have a foreground thread running, a thread you started in code.
 
There wouldn't happen to be a way to be able to see what threads are running would there? I see this threads window under debugging but it doesn't show anything. Do I need to set something in order for running threads to show up in that window? Or is this not what I think it is?

Sorry, I don't really know my way around visual studio.

Peter.
 
You have to manage your threads yourself, or set them to background that means they will abort when app shuts down, but even then it is advicable to implement thread cancelling functionality that you will preform when needed to close down everything safely.
Process.GetCurrentProcess.Threads does give you an option to iterate them and Abort all, but with the same regards as already mentioned.

Not saying threads is the only reason, but it is very common and I can't recall other reasons.
 
Back
Top