Some learning about AppDomain. DoCallBack

Source: Internet
Author: User

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 Alibaba albyrefobject
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 your albyrefobject, 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.