Re: Windows Forms apps not "ending" when you close the form window
- From: morangolds@xxxxxxxxx
- Date: 13 Sep 2006 08:43:27 -0700
Oleg Starodumov wrote:
So basically, when there's an attempt to close the app, 3 "nameless"
threads appead, and the form controls are removed from 2 of the
existing threads.
I would suspect that the application starts a worker thread
and does not terminate it properly and/or does not mark it
as background (Thread.IsBackground).
The thread, in turn, prevents the app from finishing.
This could be proved or disproved by looking at the list of threads
and their call stacks with the debugger (offending thread(s) would be visible,
and the main thread would be waiting for them to complete; RPC worker
threads could be started as a side effect (though the latter will not be visible
in the list of threads when debugging in managed or mixed mode)).
Even if my guess is wrong, the call stack of the main thread would give
some insight into what the app is currently doing.
Is it the "BroadcastEventWindow" that's preventing the app from
closing?
Probably not.
I should also mention that when in debug mode, there's no
problem ending the process by clicking "terminate all" instead of
"close", though I'm guessing that this is obvious to anyone who uses
the debugger on any regular basis.
It's good information too, since it tells that the problem is not related
to pending I/O (other possible reason for a failure to terminate properly).
Oleg
I've been breaking into the debugger at all sorts of places, and I
can't find a location which provides useful information because it's
one of two contingencies: Either it's breaking before the closing
function (whichever one it may be) is called, in which case I see what
I'd expect to see at that point, or it's managed to pass the closing
function and it's breaking, basically, right before "return 0". If the
form actually does "hang" without closing, it's hanging between the two
break points, and the stack and thread tables are empty... How do I get
the information about what's open at that particular moment, where the
app is still running, but it's within a sealed function?
Also, I've noticed the probability of a hang climbs as more system
resources are being used in the background, something I haven't noticed
until now. Since I had around 20 browser windows/tabs opened with all
sorts of references about the debugger and the managed heap, I was
bogging down the system and increasing the chances of this occurring.
After X amount of crashes on the side of other apps, which didn't like
the load on the system either, I restarted, and suddenly found that it
only froze around 20% of the time. Now I use a simple method to get it
to freeze: I play some video file in the background then I close the
app, making sure that system resources are being stressed. If the CPU
usage is high enough, it almost never closes. I'm sure this is
indicative of something, I just wish I knew what... It doesn't take
much to get it to freeze up though, just a few browser windows will
push it over 50%.
Thanks a lot for the help so far. At the very least I'm gradually
learning where to look in order to track these things down, even if not
effectively. If there's a way to break into the debugger info tables at
an arbitrary point (with my luck there probably is, and it's probably
in plain sight, I just can't find it...), that'd help a lot.
Thanks again,
-Moran
.
- Follow-Ups:
- Re: Windows Forms apps not "ending" when you close the form window
- From: Oleg Starodumov
- Re: Windows Forms apps not "ending" when you close the form window
- References:
- Windows Forms apps not "ending" when you close the form window
- From: morangolds
- Re: Windows Forms apps not "ending" when you close the form window
- From: Ben Voigt
- Re: Windows Forms apps not "ending" when you close the form window
- From: morangolds
- Re: Windows Forms apps not "ending" when you close the form window
- From: Oleg Starodumov
- Re: Windows Forms apps not "ending" when you close the form window
- From: morangolds
- Re: Windows Forms apps not "ending" when you close the form window
- From: Oleg Starodumov
- Windows Forms apps not "ending" when you close the form window
- Prev by Date: Re: auto_ptr and COM
- Next by Date: Can the GC suspend a managed thread executing native code?
- Previous by thread: Re: Windows Forms apps not "ending" when you close the form window
- Next by thread: Re: Windows Forms apps not "ending" when you close the form window
- Index(es):
Relevant Pages
|