Exemplo n.º 1
0
    public static void ThreadPoolTest()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread26.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread26.nThreads];

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

#pragma warning disable 219
        Gen <T> obj = new Gen <T>();
#pragma warning restore

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

        WaitHandle.WaitAll(hdls);
        Test_thread26.Eval(Test_thread26.Xcounter == Test_thread26.nThreads);
        Test_thread26.Xcounter = 0;
    }
Exemplo n.º 2
0
    public static void DelegateTest()
    {
        ThreadStart d = new ThreadStart(Gen <T> .Target);


        d();
        Test_thread26.Eval(Test_thread26.Xcounter == 1);
        Test_thread26.Xcounter = 0;
    }
Exemplo n.º 3
0
    public static void ThreadPoolTest()
    {
        ManualResetEvent evt = new ManualResetEvent(false);

        TimerCallback tcb   = new TimerCallback(Gen <T> .Target);
        Timer         timer = new Timer(tcb, evt, Test_thread26.delay, Test_thread26.period);

        evt.WaitOne();
        timer.Dispose();
        Test_thread26.Eval(Test_thread26.Xcounter >= Test_thread26.nThreads);
        Test_thread26.Xcounter = 0;
    }
Exemplo n.º 4
0
    public static void ThreadPoolTest()
    {
        Thread[] threads = new Thread[Test_thread26.nThreads];

        for (int i = 0; i < Test_thread26.nThreads; i++)
        {
            threads[i] = new Thread(new ThreadStart(Gen <T> .Target));
            threads[i].Start();
        }

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

        Test_thread26.Eval(Test_thread26.Xcounter == Test_thread26.nThreads);
        Test_thread26.Xcounter = 0;
    }