Example #1
0
            public TryReceiveAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool completeSelf = false;

                try
                {
                    IAsyncResult result = this.channel.BeginReceive(timeout, onReceive, this);
                    if (result.CompletedSynchronously)
                    {
                        this.CompleteReceive(result);
                        completeSelf = true;
                    }
                }
                catch (TimeoutException e)
                {
                    if (TD.ReceiveTimeoutIsEnabled())
                    {
                        TD.ReceiveTimeout(e.Message);
                    }

                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);

                    completeSelf = true;
                }

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
Example #2
0
            public SendAsyncResult(TransportDuplexSessionChannel channel, Message message, TimeSpan timeout, bool streamedOutput, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.timeoutHelper  = new TimeoutHelper(timeout);
                this.channel        = channel;
                this.message        = message;
                this.streamedOutput = streamedOutput;

                if (!channel.sendLock.EnterAsync(this.timeoutHelper.RemainingTime(), onEnterComplete, this))
                {
                    return;
                }

                bool completeSelf = false;
                bool writeSuccess = false;

                try
                {
                    completeSelf = this.WriteCore();
                    writeSuccess = true;
                }
                finally
                {
                    if (!writeSuccess)
                    {
                        this.Cleanup(false, true);
                    }
                }

                if (completeSelf)
                {
                    this.Cleanup(true, true);
                    this.Complete(true);
                }
            }
Example #3
0
            public CloseAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel       = channel;
                this.timeoutHelper = new TimeoutHelper(timeout);
                IAsyncResult result =
                    this.channel.BeginCloseOutputSession(this.timeoutHelper.RemainingTime(), onCloseOutputSession, this);

                if (!result.CompletedSynchronously)
                {
                    return;
                }

                if (!this.HandleCloseOutputSession(result, true))
                {
                    return;
                }

                this.Complete(true);
            }
Example #4
0
            public CloseOutputSessionAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                channel.ThrowIfNotOpened();
                channel.ThrowIfFaulted();

                this.timeoutHelper = new TimeoutHelper(timeout);
                this.channel       = channel;

                if (!channel.sendLock.EnterAsync(this.timeoutHelper.RemainingTime(), onEnterComplete, this))
                {
                    return;
                }

                bool completeSelf = false;
                bool writeSuccess = false;

                try
                {
                    completeSelf = this.WriteEndBytes();
                    writeSuccess = true;
                }
                finally
                {
                    if (!writeSuccess)
                    {
                        this.Cleanup(false, true);
                    }
                }

                if (completeSelf)
                {
                    this.Cleanup(true, true);
                    this.Complete(true);
                }
            }
 public ConnectionDuplexSession(TransportDuplexSessionChannel channel)
     : base()
 {
     _channel = channel;
 }
Example #6
0
 public ConnectionDuplexSession(TransportDuplexSessionChannel channel)
     : base()
 {
     Channel = channel;
 }
            public CloseOutputSessionAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                 : base(callback, state)
            {
                channel.ThrowIfNotOpened();
                channel.ThrowIfFaulted();

                this.timeoutHelper = new TimeoutHelper(timeout);
                this.channel = channel;

                if (!channel.sendLock.EnterAsync(this.timeoutHelper.RemainingTime(), onEnterComplete, this))
                {
                    return;
                }

                bool completeSelf = false;
                bool writeSuccess = false;

                try
                {
                    completeSelf = this.WriteEndBytes();
                    writeSuccess = true;
                }
                finally
                {
                    if (!writeSuccess)
                    {
                        this.Cleanup(false, true);
                    }
                }

                if (completeSelf)
                {
                    this.Cleanup(true, true);
                    this.Complete(true);
                }
            }
            public CloseAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                 : base(callback, state)
            {
                this.channel = channel;
                this.timeoutHelper = new TimeoutHelper(timeout);
                IAsyncResult result =
                    this.channel.BeginCloseOutputSession(this.timeoutHelper.RemainingTime(), onCloseOutputSession, this);

                if (!result.CompletedSynchronously)
                {
                    return;
                }

                if (!this.HandleCloseOutputSession(result, true))
                {
                    return;
                }

                this.Complete(true);
            }
            public TryReceiveAsyncResult(TransportDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;

                bool completeSelf = false;
                try
                {
                    IAsyncResult result = this.channel.BeginReceive(timeout, onReceive, this);
                    if (result.CompletedSynchronously)
                    {
                        this.CompleteReceive(result);
                        completeSelf = true;
                    }
                }
                catch (TimeoutException e)
                {
                    if (TD.ReceiveTimeoutIsEnabled())
                    {
                        TD.ReceiveTimeout(e.Message);
                    }

                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);

                    completeSelf = true;
                }

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
            public SendAsyncResult(TransportDuplexSessionChannel channel, Message message, TimeSpan timeout, bool streamedOutput, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.timeoutHelper = new TimeoutHelper(timeout);
                this.channel = channel;
                this.message = message;
                this.streamedOutput = streamedOutput;

                if (!channel.sendLock.EnterAsync(this.timeoutHelper.RemainingTime(), onEnterComplete, this))
                {
                    return;
                }

                bool completeSelf = false;
                bool writeSuccess = false;

                try
                {
                    completeSelf = this.WriteCore();
                    writeSuccess = true;
                }
                finally
                {
                    if (!writeSuccess)
                    {
                        this.Cleanup(false, true);
                    }
                }

                if (completeSelf)
                {
                    this.Cleanup(true, true);
                    this.Complete(true);
                }
            }