标签:
//服务代码 [WebMethod] public string Test(int sleepTimes, int val) { Thread.Sleep(sleepTimes); var log = AppDomain.CurrentDomain.BaseDirectory + "/logs/log.log"; using (var sw = new StreamWriter(log, true)) { sw.WriteLine(DateTime.Now.ToString() + " -> " + val.ToString()); } return DateTime.Now.ToString() + " -> " + val.ToString(); }
//asp.net 客户端 protected void btnInvoke_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem((obj) => { for (var i = 1; i < 300; i++) { var demo = new Demo(); demo.TestCompleted += (s, ex) => { if (ex.Error != null) { DbLoger.Log(ex.UserState.ToString().ToInt(), ex.Error.Message); demo.TestSyncAsync(1000, ex.UserState.ToString().ToInt()); } else { //DbLoger.Log(ex.UserState.ToString().ToInt(), ""); } }; demo.TestSyncAsync(1000, i, i); } }, "test"); Response.Write("DONE"); }
标签:
原文地址:http://www.cnblogs.com/byxxw/p/5088298.html