Esempio n. 1
0
    public static void DelegateTest()
    {
        ThreadStart d = new ThreadStart(new Gen <T>().Target);


        d();
        Test_thread07.Eval(Test_thread07.Xcounter == 1);
        Test_thread07.Xcounter = 0;
    }
Esempio n. 2
0
    public static void ThreadPoolTest()
    {
        ManualResetEvent evt = new ManualResetEvent(false);

        Gen <T> obj = new Gen <T>();

        TimerCallback tcb   = new TimerCallback(obj.Target);
        Timer         timer = new Timer(tcb, evt, Test_thread07.delay, Test_thread07.period);

        evt.WaitOne();
        timer.Dispose();
        Test_thread07.Eval(Test_thread07.Xcounter >= Test_thread07.nThreads);
        Test_thread07.Xcounter = 0;
    }
Esempio n. 3
0
    public static void ThreadPoolTest()
    {
        Thread[] threads = new Thread[Test_thread07.nThreads];
        Gen <T>  obj     = new Gen <T>();

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

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

        Test_thread07.Eval(Test_thread07.Xcounter == Test_thread07.nThreads);
        Test_thread07.Xcounter = 0;
    }
Esempio n. 4
0
    public static void ThreadPoolTest()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread07.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread07.nThreads];

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

        Gen <T> obj = new Gen <T>();

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

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