Say an AD AD#1 creates an AD#2 that loads an assembly and starts running
code in it, this AD#2 starts creating threads that transition into unmanaged
code and block, now I want to unload the assembly so I have to unload the
AD#2, please tell me how are you gonna tell the threads in AD#2 to 'exit'
from AD#1?
Willy.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ut******** ******@TK2MSFTN GP09.phx.gbl...
| Willy,
|
| The point that you missed in my response is that one shouldn't just
shut
| down app domains indiscriminatel y. If he can clean up threads, then by
all
| means, he should do so. Since he knows that Unload is going to abort his
| threads, he should take measures to exit those threads before he calls
| Unload.
|
| Since calling Unload on the AppDomain effectively calls Thread.Abort on
| any threads in the app domain, and I believe in my earlier statement about
| RARELY having a good reason to call Thread.Abort, I'm saying that if you
can
| clean up the thread(s) before a call to Unload, then do it.
|
| --
| - Nicholas Paldino [.NET/C# MVP]
| -
mv*@spam.guard. caspershouse.co m
|
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:um******** ******@tk2msftn gp13.phx.gbl...
| > The OP didn't say HE calls Thread.Abort(), he said .... AppDomain.UnLoa d
| > method (which calls the Thread.Abort... .
| > There is nothing you can do about this, it's the way Unload is
| > implemented.
| > If you are loading assemblies in auxiliary AD's, you'll have to code
| > accordingly and watch for rude aborts introduced by the CLR.
| >
| >
| > Willy.
| >
| > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
| > in
| > message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| > | I didn't imply that it didn't. What I am saying is that aborting a
| > | thread is really bad practice, and can leave a system in an
inconsistent
| > | state.
| > |
| > | I can't think of a situation where a call to Abort on a thread is
| > | justified.
| > |
| > |
| > | --
| > | - Nicholas Paldino [.NET/C# MVP]
| > | -
mv*@spam.guard. caspershouse.co m
| > |
| > | "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| > | news:eq******** ******@TK2MSFTN GP11.phx.gbl...
| > | > Abort() is called intrinsically by Unload().
| > | >
| > | > Willy.
| > | >
| > | >
| > | >
| > | > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
| > wrote
| > | > in
| > | > message news:uu******** *****@TK2MSFTNG P15.phx.gbl...
| > | > | JPSuitor,
| > | > |
| > | > | Well, the error is pretty clear. What is it that thread is
doing
| > | > which
| > | > | is taking so long?
| > | > |
| > | > | You shouldn't rely on such an abrupt shutdown. Rather, you
| > should
| > | > | signal threads that you know are running in that app domain to
shut
| > | > down,
| > | > | and then call Unload.
| > | > |
| > | > | Hope this helps.
| > | > |
| > | > |
| > | > | --
| > | > | - Nicholas Paldino [.NET/C# MVP]
| > | > | -
mv*@spam.guard. caspershouse.co m
| > | > |
| > | > | "JPSutor" <jp*****@yahoo. com> wrote in message
| > | > | news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
| > | > | > when I use the AppDomain.UnLoa d method (which calls the
| > Thread.Abort
| > | > | > method), I get the following error message
| > | > | >
| > | > | > AppDomain can not be unloaded because the thread 1378 can not be
| > | > | > unwound out of it
| > | > | >
| > | > | > It seems to take time doing this. If I wait for about 30
seconds,
| > it
| > | > | > seems to get unloaded.
| > | > | > Any ideas?
| > | > | >
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|