码迷,mamicode.com
首页 > 移动开发 > 详细

cross appdomain access

时间:2019-05-19 10:15:19      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:list()   rom   llb   task   for   ram   get   color   nbsp   

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

 

cross appdomain access

标签:list()   rom   llb   task   for   ram   get   color   nbsp   

原文地址:https://www.cnblogs.com/nanfei/p/10888078.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!