Exemplo n.º 1
0
        public void GlobalAutoResetEvent_Basic()
        {
#if WINFULL
            var thread = new Thread(new ThreadStart(ThreadProc));
#else
            var thread = new CEThread(new ThreadStart(ThreadProc));
#endif
            event1 = new GlobalAutoResetEvent("Test");
            event2 = new GlobalAutoResetEvent("Test");

            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();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles messages received from the shared memory inbox.
        /// </summary>
        /// <param name="raw">The raw message.</param>
        private void OnReceive(byte[] raw)
        {
            using (TimedLock.Lock(this))
            {
                var msg = new ServiceMsg(raw);

                if (msg.RefID != refID)
                {
                    return;     // Ignore message that aren't part of the transaction
                }

                reply = msg;
                onReply.Set();  // Wake up the query thread
            }
        }