public override void OnEnteredState()
        {
            this.checkingEvent.Reset();
            this.abortEvent.Reset();

            ThreadPool.QueueUserWorkItem(new WaitCallback(DoCheckThreadProc));

            WaitHandleArray events = new WaitHandleArray(2);

            events[0] = this.checkingEvent;
            events[1] = this.abortEvent;
            int waitResult = events.WaitAny();

            if (waitResult == 0 && manifest != null && latestVersionIndex != -1)
            {
                StateMachine.QueueInput(PrivateInput.GoToUpdateAvailable);
            }
            else if (waitResult == 1)
            {
                StateMachine.QueueInput(PrivateInput.GoToAborted);
            }
            else if (this.exception != null)
            {
                StateMachine.QueueInput(PrivateInput.GoToError);
            }
            else
            {
                StateMachine.QueueInput(PrivateInput.GoToDone);
            }
        }
Exemple #2
0
        public override void OnEnteredState()
        {
            this.checkingEvent.Reset();
            this.abortEvent.Reset();
            Work.QueueWorkItem(new WaitCallback(this.DoCheckThreadProc));
            int num = new WaitHandleArray(2)
            {
                [0] = this.checkingEvent,
                [1] = this.abortEvent
            }.WaitAny();

            if (((num == 0) && (this.manifest != null)) && (this.latestVersionIndex != -1))
            {
                base.StateMachine.QueueInput(PrivateInput.GoToUpdateAvailable);
            }
            else if (num == 1)
            {
                base.StateMachine.QueueInput(PrivateInput.GoToAborted);
            }
            else if (this.exception != null)
            {
                base.StateMachine.QueueInput(PrivateInput.GoToError);
            }
            else
            {
                base.StateMachine.QueueInput(PrivateInput.GoToDone);
            }
        }
Exemple #3
0
        private RuntimeThread()
        {
            _waitedSafeWaitHandles = new WaitHandleArray <SafeWaitHandle>(elementInitializer: null);
            _threadState           = (int)ThreadState.Unstarted;
            _priority = ThreadPriority.Normal;
            _lock     = new Lock();

#if PLATFORM_UNIX
            _waitInfo = new WaitSubsystem.ThreadWaitInfo(this);
#endif

            PlatformSpecificInitialize();
        }
        public WaitableCounter(int maxCount)
        {
            if (maxCount < 1 || maxCount > 64)
            {
                throw new ArgumentOutOfRangeException("maxCount", "must be between 1 and 64, inclusive");
            }

            this.freeEvents  = new WaitHandleArray(maxCount);
            this.inUseEvents = new WaitHandleArray(maxCount);

            for (int i = 0; i < maxCount; ++i)
            {
                this.freeEvents[i]  = new ManualResetEvent(true);
                this.inUseEvents[i] = new ManualResetEvent(false);
            }

            this.theLock = new object();
        }
Exemple #5
0
 private void PlatformSpecificInitialize()
 {
     _waitedHandles = new WaitHandleArray <IntPtr>(elementInitializer: null);
 }