public bool EndWaitForItem(IAsyncResult result)
        {
            TypedCompletedAsyncResult <bool> typedResult = result as TypedCompletedAsyncResult <bool>;

            if (typedResult != null)
            {
                return(TypedCompletedAsyncResult <bool> .End(result));
            }

            return(AsyncQueueWaiter.End(result));
        }
        public bool EndDequeue(IAsyncResult result, out T value)
        {
            TypedCompletedAsyncResult <T> typedResult = result as TypedCompletedAsyncResult <T>;

            if (typedResult != null)
            {
                value = TypedCompletedAsyncResult <T> .End(result);

                return(true);
            }

            return(AsyncQueueReader.End(result, out value));
        }