Beispiel #1
0
 public IAsyncResult BeginWaitForItem(TimeSpan timeout, AsyncCallback callback, object state)
 {
     lock (LockObject)
     {
         if (_QueueState == QueueState.Open)
         {
             if (!_ItemQueue.HasAvailableItem)
             {
                 AsyncQueueWaiter waiter = new AsyncQueueWaiter(timeout, callback, state);
                 _WaiterList.Add(waiter);
                 return(waiter);
             }
         }
         else if (_QueueState == QueueState.Shutdown)
         {
             if (!_ItemQueue.HasAvailableItem && _ItemQueue.HasAnyItem)
             {
                 AsyncQueueWaiter waiter = new AsyncQueueWaiter(timeout, callback, state);
                 _WaiterList.Add(waiter);
                 return(waiter);
             }
         }
     }
     return(new DataCompleteAsyncResult <bool>(true, callback, state));
 }
Beispiel #2
0
        public bool EndWaitForItem(IAsyncResult result)
        {
            DataCompleteAsyncResult <bool> dataResult = result as DataCompleteAsyncResult <bool>;

            if (dataResult != null)
            {
                return(DataCompleteAsyncResult <bool> .End(result));
            }
            return(AsyncQueueWaiter.End(result));
        }
Beispiel #3
0
        public static bool End(IAsyncResult asyncResult)
        {
            AsyncQueueWaiter waiterResult = ExAsyncResult.End <AsyncQueueWaiter>(asyncResult);

            return(waiterResult._ItemAvailable);
        }
Beispiel #4
0
        private static void TimerCallback(object state)
        {
            AsyncQueueWaiter thisPtr = (AsyncQueueWaiter)state;

            thisPtr.Complete(false);
        }