예제 #1
0
    public static void DelegateTest()
    {
        IGen <object> obj = new GenObject();
        ThreadStart   d   = new ThreadStart(obj.Target);


        d();
        Test_thread14.Eval(Test_thread14.Xcounter == 1);
        Test_thread14.Xcounter = 0;
    }
예제 #2
0
파일: thread14.cs 프로젝트: z77ma/runtime
    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_thread14.delay, Test_thread14.period);

        evt.WaitOne();
        timer.Dispose();
        Test_thread14.Eval(Test_thread14.Xcounter >= Test_thread14.nThreads);
        Test_thread14.Xcounter = 0;
    }
예제 #3
0
파일: thread14.cs 프로젝트: z77ma/runtime
    public static void ThreadPoolTest()
    {
        Thread[]      threads = new Thread[Test_thread14.nThreads];
        IGen <string> obj     = new GenString();

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

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

        Test_thread14.Eval(Test_thread14.Xcounter == Test_thread14.nThreads);
        Test_thread14.Xcounter = 0;
    }
예제 #4
0
파일: thread14.cs 프로젝트: z77ma/runtime
    public static void ThreadPoolTest()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread14.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread14.nThreads];

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

        IGen <double> obj = new GenDouble();

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

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