コード例 #1
0
    public static void Target <U>(object p)
    {
        //dummy line to avoid warnings
        Test_thread28.Eval(typeof(U) != p.GetType());
        ManualResetEvent evt = (ManualResetEvent)p;

        Interlocked.Increment(ref Test_thread28.Xcounter);
        evt.Set();
    }
コード例 #2
0
ファイル: thread28.cs プロジェクト: z77ma/runtime
    public static void DelegateTest <U>()
    {
        ThreadStart d = new ThreadStart(Gen <T> .Target <U>);


        d();
        Test_thread28.Eval(Test_thread28.Xcounter == 1);
        Test_thread28.Xcounter = 0;
    }
コード例 #3
0
ファイル: thread28.cs プロジェクト: z77ma/runtime
    public static void ThreadPoolTest <U>()
    {
        ManualResetEvent evt = new ManualResetEvent(false);

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

        evt.WaitOne();
        timer.Dispose();
        Test_thread28.Eval(Test_thread28.Xcounter >= Test_thread28.nThreads);
        Test_thread28.Xcounter = 0;
    }
コード例 #4
0
ファイル: thread28.cs プロジェクト: z77ma/runtime
    public static void ThreadPoolTest <U>()
    {
        Thread[] threads = new Thread[Test_thread28.nThreads];

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

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

        Test_thread28.Eval(Test_thread28.Xcounter == Test_thread28.nThreads);
        Test_thread28.Xcounter = 0;
    }
コード例 #5
0
    public static void ThreadPoolTest <U>()
    {
        ManualResetEvent[] evts = new ManualResetEvent[Test_thread28.nThreads];
        WaitHandle[]       hdls = new WaitHandle[Test_thread28.nThreads];

        for (int i = 0; i < Test_thread28.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_thread28.nThreads; i++)
        {
            WaitCallback cb = new WaitCallback(Gen <T> .Target <U>);
            ThreadPool.QueueUserWorkItem(cb, evts[i]);
        }

        WaitHandle.WaitAll(hdls);
        Test_thread28.Eval(Test_thread28.Xcounter == Test_thread28.nThreads);
        Test_thread28.Xcounter = 0;
    }
コード例 #6
0
ファイル: thread28.cs プロジェクト: z77ma/runtime
 public static void Target <U>()
 {
     //dummy line to avoid warnings
     Test_thread28.Eval(typeof(U) != null);
     Interlocked.Increment(ref Test_thread28.Xcounter);
 }