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(); } }
public void ThreadProc() { startTime = SysTime.Now; mutex2.WaitOne(); finishTime = SysTime.Now; }