Exemple #1
0
        public bool Set()
        {
            lock (this) {
                CheckDisposed();

                return(NativeEventCalls.SetEvent(SafeWaitHandle));
            }
        }
Exemple #2
0
 public bool Dispose(WaitHandle notifyObject)
 {
     if (notifyObject == null)
     {
         throw new ArgumentNullException("notifyObject");
     }
     Dispose();
     NativeEventCalls.SetEvent(notifyObject.SafeWaitHandle);
     return(true);
 }
Exemple #3
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)
                    {
#if NETCORE
                        throw new NotImplementedException();
#else
                        NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle);
                        _finalEvent = null;
#endif
                    }
                }
            } catch (ObjectDisposedException) {
                // Can happen if we called Unregister before we had time to execute Wait
                if (release)
                {
                    throw;
                }
            } finally {
                if (release)
                {
                    _waitObject.SafeWaitHandle.DangerousRelease();
                }
            }
        }
Exemple #4
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public bool Set()
        {
#if MONO
            var res = NativeEventCalls.SetEvent(safeWaitHandle);
#else
            bool res = Win32Native.SetEvent(safeWaitHandle);
#endif

            if (!res)
#if MONO
            { throw new IOException(); }
#else
            { __Error.WinIOError(); }
#endif

            return(res);
        }
        private void DoCallBack(object timedOut)
        {
            if (_callback != null)
            {
                try {
                    _callback(_state, (bool)timedOut);
                } catch {}
            }

            lock (this)
            {
                _callsInProcess--;
                if (_unregistered && _callsInProcess == 0 && _finalEvent != null)
                {
                    NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle);
                }
            }
        }
Exemple #6
0
        private void DoCallBack(object timedOut)
        {
            try {
                if (_callback != null)
                {
                    _callback(_state, (bool)timedOut);
                }
            } finally {
                lock (this)
                {
                    _callsInProcess--;
                    if (_unregistered && _callsInProcess == 0 && _finalEvent != null)
#if NETCORE
                    { EventWaitHandle.Set(_finalEvent.SafeWaitHandle); }
#else
                    { NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle); }
#endif
                }
            }
        }