/// <summary> /// /// </summary> /// <param name="sMessage"></param> public static void AsnyWriteLog(string sMessage, string title = "异常信息") { try { AsyncWriteLog synThread = new AsyncWriteLog(WriteLog); synThread.BeginInvoke(sMessage, title, null, null); } catch { } }
static void Main(string[] args) { Action <string> action = new AsyncWriteLog().WriteLog; for (int i = 0; i < 5; i++) { Console.WriteLine("这是第" + i + "次"); action.Invoke("这是第" + i + "次"); } }