Re: Relationship between Application.Exit() and AppDomain
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 17 Apr 2008 13:03:13 +0200
Hi Jeffrey,
See inline.
Willy.
""Jeffrey Tan[MSFT]"" <jetan@xxxxxxxxxxxxxxxxxxxx> wrote in message news:$PxWyWGoIHA.9016@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Willy ,Well, actually I'm not so sure it's a valid explanation, especially because I can't seem to repro the issue, even not when running four threads on a quad-core running Vista SP1.
This sounds like a promising explanation. Thank you for the sharing.
However, from principle, I am still a bit hard to understand it. The
started worker threads should run under the same priority as the GUI
threads. Even on the single-core CPU, OS kernel thread schedular will give
each thread the same time slice as long as these threads are in the same
priority. It is hard for me to understand why the CPU gives not enough time
to the GUI thread to call Thread.Abort() method.
Apparently there is a dedicated thread that serves to unload AD's in V2 (see the "Remarks" section in the AppDomain.Unload description), that means that AD Unloads are not executed on the UI thread. I assume they would use the Finalizer thread for this, but I can't confirm this for sure.
Furthermore, if I remember correctly, the CPU will boost the UI thread'sTrue, but irrelevant when the Thread.Abort is issued by another (the dedicated) thread that runs with "normal" priority level., if it's done by the finalizer thread then there shouldn't be an issue as this one run at real-time priority level.
priority making it more user friendly. So the GUI thread should have higher
priority(at least a small period) to execute the Thread.Abort() method.
Additionally, since the Thread.Abort() will cause the user-mode to
kernel-mode transition with stack-unwind which are both very consuming, I
suspect if this is another important factor for AppDomain.Unload() expires.
Anyway, I agree that real-world seldom causes this problem. Catching this
CannotUnloadAppDomainException and call AppDomain.Unload() again should
resolve this problem.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: Relationship between Application.Exit() and AppDomain
- From: "Jeffrey Tan[MSFT]"
- Re: Relationship between Application.Exit() and AppDomain
- References:
- Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Scott M.
- Re: Relationship between Application.Exit() and AppDomain
- From: Jon Skeet [C# MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Jeffrey Tan[MSFT]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: "Jeffrey Tan[MSFT]"
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: Sunny S
- Re: Relationship between Application.Exit() and AppDomain
- From: "Jeffrey Tan[MSFT]"
- Re: Relationship between Application.Exit() and AppDomain
- From: Willy Denoyette [MVP]
- Re: Relationship between Application.Exit() and AppDomain
- From: "Jeffrey Tan[MSFT]"
- Relationship between Application.Exit() and AppDomain
- Prev by Date: Re: Relationship between Application.Exit() and AppDomain
- Next by Date: .NET Runtime 2.0 Error Reporting , Event ID: 5000 Application Cras
- Previous by thread: Re: Relationship between Application.Exit() and AppDomain
- Next by thread: Re: Relationship between Application.Exit() and AppDomain
- Index(es):
Relevant Pages
|