日期:2014-05-17 浏览次数:20857 次
var sum1 = 0; var eh1 = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(h => { for (var i = 2; i <= 100; i += 2) sum1 += i; eh1.Set(); }); var sum2 = 0; var eh2 = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(h => { for (var i = 1; i <= 100; i += 2) sum2 += i; eh2.Set(); }); WaitHandle.WaitAll(new WaitHandle[] { eh1, eh2 });