Пример #1
0
            public bool Wait(TimeSpan timeout)
            {
                if (!TimeoutHelper.WaitOne(waitEvent, timeout))
                {
                    return(false);
                }

                return(this.itemAvailable);
            }
Пример #2
0
            public bool Wait(TimeSpan timeout, out T value)
            {
                bool isSafeToClose = false;

                try
                {
                    if (!TimeoutHelper.WaitOne(waitEvent, timeout))
                    {
                        if (this.inputQueue.RemoveReader(this))
                        {
                            value         = default(T);
                            isSafeToClose = true;
                            return(false);
                        }
                        else
                        {
                            waitEvent.WaitOne();
                        }
                    }

                    isSafeToClose = true;
                }
                finally
                {
                    if (isSafeToClose)
                    {
                        waitEvent.Close();
                    }
                }

                if (this.exception != null)
                {
                    throw Fx.Exception.AsError(this.exception);
                }

                value = item;
                return(true);
            }