public delegate void ProcessHandler(Model model);//委托申明
ProcessHandler msghandler = new ProcessHandler(ProcessMsg);//实例化一个委托
IAsyncResult iasyn = msghandler.BeginInvoke(model, new AsyncCallback(CompleteHandler), null);//开始执行处理过程
//主处理过程结束调用的函数
static void CompleteHandler(IAsyncResult asyn)
{
AsyncResult ar = (AsyncResult)asyn;
ProcessHandler del = (ProcessHandler)ar.AsyncDelegate;
del.EndInvoke(asyn);
}
static void ProcessMsg(Model model){
//主处理过程
}
以上是C# 利用委托进行异步处理实例代码的详细内容。更多信息请关注PHP中文网其他相关文章!