Esempio n. 1
0
        private void SetTimer(uint actualDuration)
        {
            // This function is called with the TimerQueue lock acquired
            Debug.Assert(Lock.IsAcquired);

            // Note: AutoResetEvent.WaitOne takes an Int32 value as a timeout.
            // The TimerQueue code ensures that timer duration is not greater than max Int32 value
            Debug.Assert(actualDuration <= (uint)Int32.MaxValue);
            s_nextTimerDuration = (int)actualDuration;

            // If this is the first time the timer is set then we need to create a thread that
            // will manage and respond to timer requests. Otherwise, simply signal the timer thread
            // to notify it that the timer duration has changed.
            if (s_timerEvent == null)
            {
                s_timerEvent = new AutoResetEvent(false);
                RuntimeThread thread = RuntimeThread.Create(TimerThread, 0);
                thread.IsBackground = true; // Keep this thread from blocking process shutdown
                thread.Start();
            }
            else
            {
                s_timerEvent.Set();
            }
        }
Esempio n. 2
0
            private static void CreateGateThread()
            {
                RuntimeThread gateThread = RuntimeThread.Create(GateThreadStart);

                gateThread.IsBackground = true;
                gateThread.Start();
            }
Esempio n. 3
0
            public WaitThread()
            {
                _waitHandles[0] = _changeHandlesEvent;
                RuntimeThread waitThread = RuntimeThread.Create(WaitThreadStart);

                waitThread.IsBackground = true;
                waitThread.Start();
            }
 private static bool TryCreateWorkerThread()
 {
     try
     {
         RuntimeThread workerThread = RuntimeThread.Create(WorkerThreadStart);
         workerThread.IsThreadPoolThread = true;
         workerThread.IsBackground       = true;
         workerThread.Start();
     }
     catch (ThreadStartException)
     {
         return(false);
     }
     catch (OutOfMemoryException)
     {
         return(false);
     }
     return(true);
 }