예제 #1
0
 public void Release <TResult>(RequestKey key, TResult result)
 {
     lock (this)
     {
         var waitHandle = (RequestWaitHandle <TResult>)_waitHandles[key];
         _waitHandles.Remove(key);
         waitHandle.Release(result);
     }
 }
예제 #2
0
 public void ReleaseWithException <TResult>(RequestKey key, Exception thrownException)
 {
     lock (this)
     {
         var waitHandle = (RequestWaitHandle <TResult>)_waitHandles[key];
         _waitHandles.Remove(key);
         waitHandle.ReleaseWithException(thrownException);
     }
 }
예제 #3
0
        public bool ShouldWaitForHandle <TResult>(RequestKey key, out RequestWaitHandle <TResult> waitHandle)
        {
            lock (this)
            {
                object waitHandleObject;
                if (_waitHandles.TryGetValue(key, out waitHandleObject))
                {
                    waitHandle = (RequestWaitHandle <TResult>)waitHandleObject;
                    return(true);
                }

                waitHandle        = new RequestWaitHandle <TResult>();
                _waitHandles[key] = waitHandle;

                return(false);
            }
        }