当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 在指定应用程序域中执行代码

在指定应用程序域中执行代码

点击次数:31 次 发布日期:2008-11-21 22:20:30 作者:源代码网
源代码网推荐

源代码网整理以下

以下为引用的内容:
//
// 在指定应用程序域中执行代码
//
//
//

源代码网整理以下
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();
        }
    }
}

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华