Let's say I have a non default app domain. I want to get a reference to the Default app domain and cause a thread to be created within it, that runs a piece of code. Is this possible? The only way I can think of doing this is to re-load my assembly into the Default app domain and have some logic in one of the constructors of a type that figures out it's been reloaded for the purpose of launching this new thread. That seems rather convoluted. Is there a more direct way of doing this? On the other hand if there were a way of doing it, it would seem that would circumvent the entire security model of .NET.
+3
A:
var ad = AppDomain.CreateDomain("mydomain");
ad.DoCallBack(() =>
{
var t = new System.Threading.Thread(() =>
{
Console.WriteLine();
Console.WriteLine("app domain = "
+ AppDomain.CurrentDomain.FriendlyName);
});
t.Start();
});
dan
2009-12-30 19:52:08