站长论坛
标题:
在指定应用程序域中执行代码
[打印本页]
作者:
superadmin
时间:
2008-1-6 21:44
标题:
在指定应用程序域中执行代码
//
// 在指定应用程序域中执行代码
//
//
//
using System;
using System.Collections.Generic;
using System.Text;
namespace DomainTest
{
class Program
{
private static string strKey = "Key1";
static void Main(string[] args)
{
AppDomain domaintest = AppDomain.CreateDomain("Domaintest");
string strVal = "Value1";
domaintest.SetData(strKey, strVal);
// 跨程序域调用委托
CrossAppDomainDelegate callback = delegate
{
// 取得当前程序域
AppDomain domain = AppDomain.CurrentDomain;
Console.WriteLine(string.Format("Value: {0} In {1}", domain.GetData(strKey), domain.FriendlyName));
};
// 在指定程序域中执行代码
domaintest.DoCallBack(callback);
Console.Read();
}
}
}
欢迎光临 站长论坛 (http://tzlink.com/bbs/)
Powered by Discuz! X3.2