Ejemplo n.º 1
0
        public void GlobalMutex_Basic()
        {
#if WINFULL
            var thread = new Thread(new ThreadStart(ThreadProc));
#else
            var thread = new CEThread(new ThreadStart(ThreadProc));
#endif
            mutex1 = new GlobalMutex("Test");
            mutex2 = new GlobalMutex("Test");

            try
            {
                mutex1.WaitOne();
                thread.Start();
                Thread.Sleep(1100);
                mutex1.ReleaseMutex();
                Thread.Sleep(1000);

                Assert.IsTrue(finishTime - startTime >= TimeSpan.FromMilliseconds(1000));
            }
            finally
            {
                mutex1.Close();
                mutex2.Close();
                thread.Join();
            }
        }
Ejemplo n.º 2
0
        public void GlobalManualResetEvent_Basic()
        {
#if WINFULL
            var thread = new Thread(new ThreadStart(ThreadProc));
#else
            var thread = new CEThread(new ThreadStart(ThreadProc));
#endif
            bool actual;

            event1 = new GlobalManualResetEvent("Test", false, out actual);
            event2 = new GlobalManualResetEvent("Test");

            Assert.IsFalse(actual);

            try
            {
                thread.Start();
                Thread.Sleep(1100);
                event1.Set();
                Thread.Sleep(1000);

                Assert.IsTrue(finishTime - startTime >= TimeSpan.FromMilliseconds(1000));
            }
            finally
            {
                event1.Close();
                event2.Close();
                thread.Join();
            }
        }