473,581 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AppDomain closing ?

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?

Jan 9 '06 #1
22 3795
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?

Jan 9 '06 #2
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?
| >
|
|
Jan 9 '06 #3

"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?
|

The CLR will orce a rude abort when a Thread.Abort() times out. This is the
CLR's normal behavior, the system can't wait forever for an AD unload. Your
issue is that your thread runs or is blocked in unmanaged code, all you can
do is resume this blocking thread or make sure threads don't stay that long
in unmanaged code.

Willy.
Jan 9 '06 #4
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?
| >
|
|

Jan 9 '06 #5
Try using Thread.Join after signaling threads you want to terminate, then on
return call AppDomain.Unloa d().

Cheers
Simon.

"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?

Jan 9 '06 #6
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?
| > | >
| > |
| > |
| >
| >
|
|
Jan 9 '06 #7
Thread.Join isn't of any help when unloading an AD which has threads that
stay running or blocking for a long period in "unmanaged land".
Willy.

"Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message
news:Ob******** ******@TK2MSFTN GP09.phx.gbl...
| Try using Thread.Join after signaling threads you want to terminate, then
on
| return call AppDomain.Unloa d().
|
| Cheers
| Simon.
|
| "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?
| >
|
|
Jan 9 '06 #8
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?
| > | >
| > |
| > |
| >
| >
|
|

Jan 9 '06 #9

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?
| > | > | >
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Jan 9 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
15350
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have the same class/static method definition statictly linked to my EXE and when I call InvokeMember(...), even though I got the Type from the new AppDomain,...
1
1362
by: JJ | last post by:
Can some one please explain me what do I need for creating a 2nd AppDomain. I've been reading the .NET framework help and googling around for examples, but don't really understand how the AppDomain works. I have a class MainForm, which is the mainprogram. The MainForm uses a class RemotingServer which handles my remoting stuff. Now, I need...
4
2344
by: Chris Lacey | last post by:
Hi, I'm currently writing a scheduling service which starts a number DotNet executables, each within a new AppDomain, every ten seconds. The guts of the code is as follows: // For each executable in the list of tasks for (int i = 0; i < this.processTasks.Length; i++) {
4
5333
by: illegal.prime | last post by:
Hi all, I'm getting unexpected results when trying to preload assemblies into an AppDomain I'm creating. Upon creation of the AppDomain - I attach an AssemblyResolve to both my current AppDomain and the new AppDomain I create. I copy all the assemblies/dlls into a new directory and then try loading them all into the new AppDomain using the...
0
7862
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8169
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6551
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5361
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.