public static void DelegateTest() { IGen <object> obj = new GenObject(); ThreadStart d = new ThreadStart(obj.Target); d(); Test_thread15.Eval(Test_thread15.Xcounter == 1); Test_thread15.Xcounter = 0; }
public static void ThreadPoolTest() { ManualResetEvent evt = new ManualResetEvent(false); IGen <double> obj = new GenDouble(); TimerCallback tcb = new TimerCallback(obj.Target); Timer timer = new Timer(tcb, evt, Test_thread15.delay, Test_thread15.period); evt.WaitOne(); timer.Dispose(); Test_thread15.Eval(Test_thread15.Xcounter >= Test_thread15.nThreads); Test_thread15.Xcounter = 0; }
public static void ThreadPoolTest() { Thread[] threads = new Thread[Test_thread15.nThreads]; IGen <string> obj = new GenString(); for (int i = 0; i < Test_thread15.nThreads; i++) { threads[i] = new Thread(new ThreadStart(obj.Target)); threads[i].Start(); } for (int i = 0; i < Test_thread15.nThreads; i++) { threads[i].Join(); } Test_thread15.Eval(Test_thread15.Xcounter == Test_thread15.nThreads); Test_thread15.Xcounter = 0; }
public static void ThreadPoolTest() { ManualResetEvent[] evts = new ManualResetEvent[Test_thread15.nThreads]; WaitHandle[] hdls = new WaitHandle[Test_thread15.nThreads]; for (int i = 0; i < Test_thread15.nThreads; i++) { evts[i] = new ManualResetEvent(false); hdls[i] = (WaitHandle)evts[i]; } IGen <double> obj = new GenDouble(); for (int i = 0; i < Test_thread15.nThreads; i++) { WaitCallback cb = new WaitCallback(obj.Target); ThreadPool.QueueUserWorkItem(cb, evts[i]); } WaitHandle.WaitAll(hdls); Test_thread15.Eval(Test_thread15.Xcounter == Test_thread15.nThreads); Test_thread15.Xcounter = 0; }