//1.异步调用 //带参 Action<object> action=(obj)=>method(obj); action.BeginInvoke(obj,ar=>action.EndInvoke(ar),null); //不带参 Action action=()=>method(); action.BeginInvoke(ar=>action.EndInvoke(ar),null); //2.异步调用 public class AsyncThread { /// <summary> /// 异步执行 /// </summary> /// <param name="method"></param> public static void Run(AsynsProp.ProcessTask method) { AsynsProp at = new AsynsProp(); at.Start(method); } } public class AsynsProp { public delegate void ProcessTask(); /// <summary> /// 使用委托做参数执行外面的代码 /// </summary> /// <param name="processTask"></param> public void Start(ProcessTask processTask) { if (processTask != null) { processTask.BeginInvoke(new AsyncCallback(End), processTask); } } /// <summary> /// Ends the long running process. /// </summary> /// <param name="result">The result.</param> public void End(IAsyncResult result) { ProcessTask processTask = (ProcessTask)result.AsyncState; processTask.EndInvoke(result); } }