示例#1
0
文件: thread13.cs 项目: z77ma/runtime
    public static void DelegateTest()
    {
        IGen <object> obj = new GenObject();
        ThreadStart   d   = new ThreadStart(obj.Target);


        d();
        Test_thread13.Eval(Test_thread13.Xcounter == 1);
        Test_thread13.Xcounter = 0;
    }
示例#2
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_thread13.delay, Test_thread13.period);

        evt.WaitOne();
        timer.Dispose();
        Test_thread13.Eval(Test_thread13.Xcounter >= Test_thread13.nThreads);
        Test_thread13.Xcounter = 0;
    }
示例#3
0
文件: thread13.cs 项目: z77ma/runtime
    public static void ThreadPoolTest()
    {
        Thread[]      threads = new Thread[Test_thread13.nThreads];
        IGen <string> obj     = new GenString();

        for (int i = 0; i < Test_thread13.nThreads; i++)
        {
            threads[i] = new Thread(new ThreadStart(obj.Target));
            threads[i].Start();
        }

        for (int i = 0; i < Test_thread13.nThreads; i++)
        {
            threads[i].Join();
        }

        Test_thread13.Eval(Test_thread13.Xcounter == Test_thread13.nThreads);
        Test_thread13.Xcounter = 0;
    }
示例#4
0
    public static void ThreadPoolTest()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread13.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread13.nThreads];

        for (int i = 0; i < Test_thread13.nThreads; i++)
        {
            evts[i] = new ManualResetEvent(false);
            hdls[i] = (WaitHandle)evts[i];
        }

        IGen <double> obj = new GenDouble();

        for (int i = 0; i < Test_thread13.nThreads; i++)
        {
            WaitCallback cb = new WaitCallback(obj.Target);
            ThreadPool.QueueUserWorkItem(cb, evts[i]);
        }

        WaitHandle.WaitAll(hdls);
        Test_thread13.Eval(Test_thread13.Xcounter == Test_thread13.nThreads);
        Test_thread13.Xcounter = 0;
    }