标签:
/// <summary> /// 异步委托 /// </summary> public delegate void AsyncHandler(); public static class AsyncHelper { public static void AsyncResult(AsyncHandler asyncHandler) { IAsyncResult asyncResult = asyncHandler.BeginInvoke(new AsyncCallback(endInvoke), asyncHandler); } //异步回调 private static void endInvoke(IAsyncResult ar) { AsyncHandler invoke = (AsyncHandler)ar.AsyncState; invoke.EndInvoke(ar); } }
代码调用:
//异步执行 AsyncHelper.AsyncResult(() => { //执行代码 });
标签:
原文地址:http://www.cnblogs.com/dragon-L/p/4871459.html