예제 #1
0
    public void Target <U>(object p)
    {
        //dummy line to avoid warnings
        Test_thread17.Eval(typeof(U) != p.GetType());
        ManualResetEvent evt = (ManualResetEvent)p;

        Interlocked.Increment(ref Test_thread17.Xcounter);
        evt.Set();
    }
예제 #2
0
파일: thread17.cs 프로젝트: z77ma/runtime
    public static void DelegateTest <U>()
    {
        IGen        obj = new Gen();
        ThreadStart d   = new ThreadStart(obj.Target <U>);


        d();
        Test_thread17.Eval(Test_thread17.Xcounter == 1);
        Test_thread17.Xcounter = 0;
    }
예제 #3
0
    public static void ThreadPoolTest <U>()
    {
        ManualResetEvent evt = new ManualResetEvent(false);

        IGen obj = new Gen();

        TimerCallback tcb   = new TimerCallback(obj.Target <U>);
        Timer         timer = new Timer(tcb, evt, Test_thread17.delay, Test_thread17.period);

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

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

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

        Test_thread17.Eval(Test_thread17.Xcounter == Test_thread17.nThreads);
        Test_thread17.Xcounter = 0;
    }
예제 #5
0
    public static void ThreadPoolTest <U>()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread17.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread17.nThreads];

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

        IGen obj = new Gen();

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

        WaitHandle.WaitAll(hdls);
        Test_thread17.Eval(Test_thread17.Xcounter == Test_thread17.nThreads);
        Test_thread17.Xcounter = 0;
    }
예제 #6
0
파일: thread17.cs 프로젝트: z77ma/runtime
 public void Target <U>()
 {
     //dummy line to avoid warnings
     Test_thread17.Eval(typeof(U) != null);
     Interlocked.Increment(ref Test_thread17.Xcounter);
 }