zoukankan      html  css  js  c++  java
  • Some learning about AppDomain.DoCallBack

    Let's first see the MSDN document about this method: http://msdn.microsoft.com/en-us/library/system.appdomain.docallback.aspx

    The three examples are good, but helping yourself to understand better, you may need to twist them a little...

    Summary (the following is based on my understanding, for any mistake please comment below :))

    There are three scenarios for DoCallBack method applies:

    1. use Static DoCallBack method,
    In this, neither default or new domain owns the field and MyCallBack code, they share the same.

    2. use DoCallBack method by value, --modified with [Serializable]
    In this, default domain owns the first-hand data and the new domain just owns a second-hand copy.

    3. use DoCallBack method by reference, -- let class inherit from MarshalByRefObject
    In this, default domain owns the only real data but the new domain just keep a reference to the data (class fields and methods).

    Hope this explains better, addition to the MSDN document.

    So, we can also explain why everytime we try to make a new Form in a new Domain, it always seems to be failed... as Form class inherit from MarshalByRefObject, and in a new Domain it only keeps the reference, yes just a reference, all the Callbacks and data happen in the Default Domain actually.

  • 相关阅读:
    P2813 母舰
    P5367 【模板】康托展开
    P1816 忠诚
    P3865 【模板】ST表
    P1913 L国的战斗之伞兵
    P4939 Agent2
    P1894 [USACO4.2]完美的牛栏The Perfect Stall
    P5017 摆渡车
    P1330 封锁阳光大学
    P5018 对称二叉树
  • 原文地址:https://www.cnblogs.com/feishunji/p/1413582.html
Copyright © 2011-2022 走看看