SetEvent_internal() private method

private SetEvent_internal ( IntPtr handle ) : bool
handle System.IntPtr
return bool
コード例 #1
0
        internal void Wait(object state)
        {
            try
            {
                WaitHandle[] waits = new WaitHandle[] { _waitObject, _cancelEvent };
                do
                {
                    int signal = WaitHandle.WaitAny(waits, _timeout, false);
                    if (!_unregistered)
                    {
                        lock (this)
                        {
                            _callsInProcess++;
                        }
                        ThreadPool.QueueUserWorkItem(new WaitCallback(DoCallBack), (signal == WaitHandle.WaitTimeout));
                    }
                }while (!_unregistered && !_executeOnlyOnce);
            }
            catch {}

            lock (this)
            {
                _unregistered = true;
                if (_callsInProcess == 0 && _finalEvent != null)
                {
                    NativeEventCalls.SetEvent_internal(_finalEvent.Handle);
                }
            }
        }
コード例 #2
0
 internal void Wait(object state)
 {
     try
     {
         WaitHandle[] waitHandles = new WaitHandle[]
         {
             this._waitObject,
             this._cancelEvent
         };
         do
         {
             int num = WaitHandle.WaitAny(waitHandles, this._timeout, false);
             if (!this._unregistered)
             {
                 lock (this)
                 {
                     this._callsInProcess++;
                 }
                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.DoCallBack), num == 258);
             }
         }while (!this._unregistered && !this._executeOnlyOnce);
     }
     catch
     {
     }
     lock (this)
     {
         this._unregistered = true;
         if (this._callsInProcess == 0 && this._finalEvent != null)
         {
             NativeEventCalls.SetEvent_internal(this._finalEvent.Handle);
         }
     }
 }
コード例 #3
0
        internal void SignalNoCallbacksRunning()
        {
#if !MONO
            Win32Native.SetEvent(m_notifyWhenNoCallbacksRunning.SafeWaitHandle);
#else
            NativeEventCalls.SetEvent_internal(m_notifyWhenNoCallbacksRunning.SafeWaitHandle.DangerousGetHandle());
#endif
        }
コード例 #4
0
ファイル: EventWaitHandle.cs プロジェクト: fragmental/mono
        public bool Set()
        {
            lock (this) {
                CheckDisposed();

                return(NativeEventCalls.SetEvent_internal(Handle));
            }
        }
コード例 #5
0
 public bool Dispose(WaitHandle notifyObject)
 {
     if (notifyObject == null)
     {
         throw new ArgumentNullException("notifyObject");
     }
     Dispose();
     NativeEventCalls.SetEvent_internal(notifyObject.Handle);
     return(true);
 }
コード例 #6
0
 private void DoCallBack(object timedOut)
 {
     if (this._callback != null)
     {
         this._callback(this._state, (bool)timedOut);
     }
     lock (this)
     {
         this._callsInProcess--;
         if (this._unregistered && this._callsInProcess == 0 && this._finalEvent != null)
         {
             NativeEventCalls.SetEvent_internal(this._finalEvent.Handle);
         }
     }
 }
コード例 #7
0
        internal void Wait(object state)
        {
            bool release = false;

            try {
                _waitObject.SafeWaitHandle.DangerousAddRef(ref release);
                try {
                    WaitHandle[] waits = new WaitHandle[] { _waitObject, _cancelEvent };
                    do
                    {
                        int signal = WaitHandle.WaitAny(waits, _timeout, false);
                        if (!_unregistered)
                        {
                            lock (this) {
                                _callsInProcess++;
                            }
                            ThreadPool.QueueUserWorkItem(new WaitCallback(DoCallBack), (signal == WaitHandle.WaitTimeout));
                        }
                    } while (!_unregistered && !_executeOnlyOnce);
                } catch {
                }

                lock (this) {
                    _unregistered = true;
                    if (_callsInProcess == 0 && _finalEvent != null)
                    {
                        NativeEventCalls.SetEvent_internal(_finalEvent.Handle);
                    }
                }
            } catch (ObjectDisposedException) {
                // Can happen if we called Unregister before we had time to execute Wait
                if (release)
                {
                    throw;
                }
            } finally {
                if (release)
                {
                    _waitObject.SafeWaitHandle.DangerousRelease();
                }
            }
        }
コード例 #8
0
 /// <summary>Sets the state of the event to signaled, allowing one or more waiting threads to proceed.</summary>
 /// <returns>true if the operation succeeds; otherwise, false.</returns>
 /// <exception cref="T:System.ObjectDisposedException">The <see cref="M:System.Threading.EventWaitHandle.Close" /> method was previously called on this <see cref="T:System.Threading.EventWaitHandle" />.</exception>
 /// <filterpriority>2</filterpriority>
 public bool Set()
 {
     base.CheckDisposed();
     return(NativeEventCalls.SetEvent_internal(this.Handle));
 }
コード例 #9
0
 public bool Dispose(WaitHandle notifyObject)
 {
     Dispose();
     NativeEventCalls.SetEvent_internal(notifyObject.Handle);
     return(true);
 }