Exemplo 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();
            }
        }
Exemplo n.º 2
0
            private static void CreateGateThread()
            {
                RuntimeThread gateThread = RuntimeThread.Create(GateThreadStart);

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

                waitThread.IsBackground = true;
                waitThread.Start();
            }
Exemplo n.º 4
0
        public Thread(ParameterizedThreadStart start)
        {
            if (start == null)
            {
                throw new ArgumentNullException(nameof(start));
            }

            _runtimeThread = RuntimeThread.Create(ThreadMain_ParameterizedThreadStart);
            Debug.Assert(_runtimeThread != null);
            _start = start;
        }
Exemplo n.º 5
0
        public Thread(ParameterizedThreadStart start, int maxStackSize)
        {
            if (start == null)
            {
                throw new ArgumentNullException(nameof(start));
            }
            if (maxStackSize < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonnegativeNumber);
            }

            _runtimeThread = RuntimeThread.Create(ThreadMain_ParameterizedThreadStart, maxStackSize);
            Debug.Assert(_runtimeThread != null);
            _start = 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);
 }