示例#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);
            }
        }