public TryReceiveAsyncResult(TimeSpan timeout, SizedTcpDuplexChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool completeSelf = true;

                if (!channel.IsDisposed)
                {
                    try
                    {
                        IAsyncResult beginReceiveRequestResult = this.channel.BeginReceive(timeout, OnReceive, this);
                        if (beginReceiveRequestResult.CompletedSynchronously)
                        {
                            CompleteReceive(beginReceiveRequestResult);
                        }
                        else
                        {
                            completeSelf = false;
                        }
                    }
                    catch (TimeoutException)
                    {
                    }
                }

                if (completeSelf)
                {
                    base.Complete(true);
                }
            }
Ejemplo n.º 2
0
            public TryReceiveAsyncResult(TimeSpan timeout, SizedTcpDuplexChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool completeSelf = true;
                if (!channel.IsDisposed)
                {
                    try
                    {
                        IAsyncResult beginReceiveRequestResult = this.channel.BeginReceive(timeout, OnReceive, this);
                        if (beginReceiveRequestResult.CompletedSynchronously)
                        {
                            CompleteReceive(beginReceiveRequestResult);
                        }
                        else
                        {
                            completeSelf = false;
                        }
                    }
                    catch (TimeoutException)
                    {
                    }
                }

                if (completeSelf)
                {
                    base.Complete(true);
                }
            }