Beispiel #1
0
            bool CompletePreData(IAsyncResult result)
            {
                channel.EndSocketSend(result);

                IAsyncResult sendDataResult = channel.BeginSocketSend(data, sendDataCallback, this);

                if (!sendDataResult.CompletedSynchronously)
                {
                    return(false);
                }

                return(CompleteSendData(sendDataResult));
            }
Beispiel #2
0
            public WriteDataAsyncResult(ArraySegment <byte> data, TimeSpan timeout, WseTcpDuplexSessionChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;
                this.data    = data;
                bool success = false;

                try
                {
                    preDataBytes = this.channel.GetPreDataBuffer(data);

                    IAsyncResult preDataResult = channel.BeginSocketSend(preDataBytes, preDataCallback, this);
                    if (!preDataResult.CompletedSynchronously)
                    {
                        return;
                    }

                    if (CompletePreData(preDataResult))
                    {
                        Cleanup();
                        base.Complete(true);
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        Cleanup();
                    }
                }
            }
            public WriteDataAsyncResult(ArraySegment<byte> data, TimeSpan timeout, WseTcpDuplexSessionChannel channel, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;
                this.data = data;
                bool success = false;
                try
                {
                    preDataBytes = this.channel.GetPreDataBuffer(data);

                    IAsyncResult preDataResult = channel.BeginSocketSend(preDataBytes, preDataCallback, this);
                    if (!preDataResult.CompletedSynchronously)
                    {
                        return;
                    }

                    if (CompletePreData(preDataResult))
                    {
                        Cleanup();
                        base.Complete(true);
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        Cleanup();
                    }
                }
            }