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>
        /// Releases any resources associated with the service control instance.
        /// </summary>
        public void Close()
        {
            id       = Guid.Empty;
            isOpen   = false;
            services = null;

            if (inbox != null)
            {
                inbox.Close();
                inbox = null;
            }

            if (outbox != null)
            {
                outbox.Close();
                outbox = null;
            }

            if (onReply != null)
            {
                onReply.Close();
                onReply = null;
            }
        }