Groups | Blog | Home
all groups > dotnet framework > november 2007 >

dotnet framework : AppDomain and Multi-Threading



Kai Iske
11/28/2007 11:58:21 AM
Hi,

following situation (this is still .NET 1.1 - *sigh*)

For a scheduling application, I create a Thread for every task that is
due to be executed. Once a task execution is due, a running Thread
will be created. The runner thread in turn will instantiate a
TaskRunner object in a new AppDomain, so it is like that. The
TaskRunner then instantiates the Task class and calls a method on an
interface:

1. Create New Thread
2. Thread creates new AppDomain
3. TaskRunner is created in new AppDomain
4. TaskRunner instantiates task class and executes interface method

2. - 4. all happen on the same (newly created thread)

After the TaskRunner has executed the task method, it cleans up,
however when the Thread calls to unload the AppDomain it previously
created, the whole thread is aborted and no code is executed anymore
after the unload.

I don't quite understand why this would happen. My worker thread runs
on the main AppDomain and creates/unloads a child AppDomain. I wonder
why unloading that child AppDomain would kill my worker thread.

Any help would be highly appreciated.

Thanks

Ross Presser
12/4/2007 12:20:35 PM
[quoted text, click to view]

Is an exception thrown when you unload? I'd start there, put a try/
AddThis Social Bookmark Button