473,670 Members | 2,673 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 3807
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
15361
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, it calls the static method that I am staticly linked to and not the static method in the dynamicly...
1
1365
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 to put the RemotingServer to the a 2nd AppDomain, so that I can stop and restart the remoting...
4
2348
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
5337
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 following: private void LoadAssembliesFromDirectory(AppDomain appDomain, string directory)
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8660
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5683
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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
2
1792
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.