using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading;
namespace ConsoleApplication5 { public class ThreadCallBackTest { /// <summary> /// 记录正常完成的子线程数 /// </summary> int count = 0;
/// <summary> /// 主函数 /// </summary> /// <returns></returns> public bool Run() { //总线程数 int total = 10; MyParam m; List<Thread> listThread = new List<Thread>(); for (int i = 0; i < total; i++) { m = new MyParam(); m.x = i; m.y = i + 1; m.callBack = ThreadCallBack; Thread t = new Thread(new ParameterizedThreadStart(Buss)); t.Start(m); listThread.Add(t); }
//等待所有线程完成 foreach (var item in listThread) { item.Join(); }