html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

在指定应用程序域中执行代码_.NET教程_编程技术

[ ] 已经帮助:人解决问题
程序|执行

超级入门级:) 哈哈~ 留个纪念。
//
// 在指定应用程序域中执行代码
//
//
//


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();
        }
    }
}

aj5HTML5中文学习网 - HTML5先行者学习网
aj5HTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助