基本上,從我所瞭解的我已經設法在互聯網上搜索到的一點,線程可以在AppDomains之間傳遞。現在,我已經寫了下面的代碼:AppDomain和線程
const string ChildAppDomain = "BlahBlah";
static void Main()
{
if (AppDomain.CurrentDomain.FriendlyName != ChildAppDomain)
{
bool done = false;
while (!done)
{
AppDomain mainApp = AppDomain.CreateDomain(ChildAppDomain, null, AppDomain.CurrentDomain.SetupInformation);
try
{
mainApp.ExecuteAssembly(Path.GetFileName(Application.ExecutablePath));
}
catch (Exception ex)
{
// [snip]
}
AppDomain.Unload(mainApp);
}
}
else
{
// [snip] Rest of the program goes here
}
}
這工作得很好,一切都點擊進入地方...主線程通過到我的程序的新版本,並開始通過主應用程序體運行。我的問題是,我將如何去讓它回到父母AppDomain
?這可能嗎?我想要實現的是在兩個域之間共享一個類的實例。
任何指針,以良好的資源就怎麼做遠程處理? – 2009-06-26 12:50:59