• 跨AppDomain通信


    public class AppDomainTest : MarshalByRefObject
        {
           public string TestMethodStr(string srcAppDomain)
            {
                string TTT = "TTT";
    
                byte[] m_ExtraMemory = new byte[1024 * 1024 * 99];
    
                Console.WriteLine(
                "Code from the '{0}' AppDomain
    " +
                "called into the '{1}'. AppDomain.",
                srcAppDomain, Thread.GetDomain().FriendlyName);
    
    
                Console.WriteLine(
               "Code from the  TTT= '{0}' AppDomain
    " +
               "called into the '{1}'. AppDomain.",
               TTT, Thread.GetDomain().FriendlyName);
                return TTT;
    
            }
        }

    static void Main(string[] args)
    {

    AppDomain domainArcher = AppDomain.CreateDomain("MyNewDomain", null, null);
    AppDomainTest test1 = (AppDomainTest)domainArcher.CreateInstanceAndUnwrap(System.Reflection.Assembly.GetCallingAssembly().FullName, "ConsoleApp1.AppDomainTest");

    var tt1 = test1.TestMethodStr(Thread.GetDomain().FriendlyName);

    Console.ReadLine();

       }

    进程内 AppDomain 间通信,但实测下,效率太慢了,只适合某些特殊情况下使用

  • 相关阅读:
    Floyd最小环
    D
    C
    B
    HPU personal training
    D
    A
    简练网软考知识点整理-项目风险审计及风险评估
    简练网软考知识点整理-项目需求跟踪及需求跟踪矩阵
    简练网软考知识点整理-项目资源优化、资源平衡及资源平滑
  • 原文地址:https://www.cnblogs.com/panjinzhao/p/11103512.html
Copyright © 2020-2023  润新知