C# uses delegation for asynchronous processing example code

零下一度
Release: 2017-06-26 15:35:01
Original
1474 people have browsed it

public delegate void ProcessHandler(Model model);//Delegation declaration

ProcessHandler msghandler = new ProcessHandler(ProcessMsg);//Instantiate a delegate
IAsyncResult iasyn = msghandler.BeginInvoke(model, new AsyncCallback(CompleteHandler), null);//Start executing the processing process
//The function called when the main processing process ends
static void CompleteHandler(IAsyncResult asyn)
{
AsyncResult ar = (AsyncResult)asyn ;
ProcessHandler del = (ProcessHandler)ar.AsyncDelegate;
del.EndInvoke(asyn);
}

static void ProcessMsg(Model model){
//Main processing process
}

The above is the detailed content of C# uses delegation for asynchronous processing example code. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!