zoukankan      html  css  js  c++  java
  • cross appdomain access

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApp6
    {
        class Program
        {
            static string greetings = "PONG!";
    
            static void Main(string[] args)
            {
                AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
    
                greetings = "PING!";
                MyCallBack();
                otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack));
    
                // Output:
                // PING! from defaultDomain
                // PONG! from otherDomain
                Console.In.ReadLine();
            }
    
            public static void MyCallBack()
            {
                string name = AppDomain.CurrentDomain.FriendlyName;
    
                if (name == AppDomain.CurrentDomain.SetupInformation.ApplicationName)
                {
                    name = "defaultDomain";
                }
                Console.WriteLine(greetings + " from " + name);
    
                var list = AppDomain.CurrentDomain.GetAssemblies().ToList();
            }
        }
    }

    result:

    PING! from defaultDomain
    PONG! from otherDomain
  • 相关阅读:
    demo04-默认标签
    demo03-段落标签
    demo02-标题标签
    demo01-注释标签
    前端基础介绍
    xadmin的详细使用
    设置Linux环境变量中文显示乱码
    ES应用
    HTTP协议
    jboss
  • 原文地址:https://www.cnblogs.com/nanfei/p/10888078.html
Copyright © 2011-2022 走看看