One of my asynchronous UML operations

Source: Internet
Author: User

Reference:
Asynchronous programming of mcad learning notes (asynccallback delegation, iasyncresult interface, begininvoke method, and endinvoke method)

Http://www.cnblogs.com/aierong/archive/2005/05/25/162308.html

Delegated re-understanding of mcad learning notes (discussion of Delegate constructor, begininvoke, endinvoke, and invoke4 methods)

Http://www.cnblogs.com/aierong/archive/2005/05/25/162181.html

It's classic.Article. All at once solved my understanding of iasyncresult.

In fact, there are four asynchronous modes of ASP. NET, which can be implemented using the functions provided by iasyncresult flexibly. I will use the asynceventhandler proxy to complete all my asynchronous operations.

 

Core of the buffer layer Code : Public   Delegate   Void Asynceventhandler (); // Declare an asynchronous proxy
Public   Class Connectionpipe
... {
Private   Event Asynceventhandler asy; // Instantiate proxy
Private Contentfetcher fetcher; // Get data class
Public Iasyncresult begincalling (asynccallback CB, String Param)
... {
If (CB =   Null )
Throw   New Exception ( " Missing para! " );
If (Param =   Null   | Param =   "" )
Throw   New Exception ( " Missing para! " );
Fetcher =   New Contentfetcher (pathmappingcontroller. instance. getpath (PARAM ));
Asy =   New Asynceventhandler (Fetcher. Fetching );
Return Asy. begininvoke ( New Asynccallback (CB ), This );
}

Public   Void Endcalling (iasyncresult AR)
... {
If(Asy= Null)
Throw NewException ("Run begincalling first!");
Asy. endinvoke (AR );
}

Public   String Content
... {
Get ...{ReturnFetcher. content ;}
}
} Page code: Public   Partial   Class Subpages_03projects_lenovo: system. Web. UI. Page
... {
Protected   String Pagecontent;
Protected   Void Page_load ( Object Sender, eventargs E)
... {
Addonprerendercompleteasync (
NewBegineventhandler (beginasyncoperation ),
NewEndeventhandler (endasyncoperation)
);
}
Iasyncresult beginasyncoperation ( Object Sender, eventargs e,
Asynccallback CB, Object State)
... {
Connectionpipe Pipe= NewConnectionpipe ();
ReturnPipe. begincalling (CB,"Testme");
}
Void Endasyncoperation (iasyncresult AR)
... {
(AR. asyncstateAsConnectionpipe). endcalling (AR );
Pagecontent=(AR. asyncstateAsConnectionpipe). content;
}
} Thought :. Start the page and call connectionpipe asynchronously to obtain data .. When the data is obtained, the automatic call ends .. The asynchronous operations provided in the proxy are used: begininvoke and endinvoke, so that I do not need to implement the iasyncresult interface myself .. The proxy automatically calls asynccallback after the method operation is completed. This saves me a lot of trouble. Asp.net asynchronous learning is complete.

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.