StartWriting() private method

private StartWriting ( byte buffer, int offset, int count, AsyncProtocolRequest asyncRequest ) : void
buffer byte
offset int
count int
asyncRequest AsyncProtocolRequest
return void
Exemplo n.º 1
0
        //
        //
        //
        private static void WriteCallback(IAsyncResult transportResult)
        {
            if (transportResult.CompletedSynchronously)
            {
                return;
            }
            GlobalLog.Assert(transportResult.AsyncState is AsyncProtocolRequest, "NegotiateSteam::WriteCallback|State type is wrong, expected AsyncProtocolRequest.");

            AsyncProtocolRequest asyncRequest = (AsyncProtocolRequest)transportResult.AsyncState;

            try {
                NegotiateStream negoStream = (NegotiateStream)asyncRequest.AsyncObject;
                negoStream.InnerStream.EndWrite(transportResult);
                if (asyncRequest.Count == 0)
                {
                    // this was the last chunk
                    asyncRequest.Count = -1;
                }
                negoStream.StartWriting(asyncRequest.Buffer, asyncRequest.Offset, asyncRequest.Count, asyncRequest);
            }
            catch (Exception e) {
                if (asyncRequest.IsUserCompleted)
                {
                    // This will throw on a worker thread.
                    throw;
                }
                asyncRequest.CompleteWithError(e);
            }
        }
 private static void WriteCallback(IAsyncResult transportResult)
 {
     if (!transportResult.CompletedSynchronously)
     {
         AsyncProtocolRequest asyncState = (AsyncProtocolRequest)transportResult.AsyncState;
         try
         {
             NegotiateStream asyncObject = (NegotiateStream)asyncState.AsyncObject;
             asyncObject.InnerStream.EndWrite(transportResult);
             if (asyncState.Count == 0)
             {
                 asyncState.Count = -1;
             }
             asyncObject.StartWriting(asyncState.Buffer, asyncState.Offset, asyncState.Count, asyncState);
         }
         catch (Exception exception)
         {
             if (asyncState.IsUserCompleted)
             {
                 throw;
             }
             asyncState.CompleteWithError(exception);
         }
     }
 }
Exemplo n.º 3
0
        private static void WriteCallback(IAsyncResult transportResult)
        {
            if (transportResult.CompletedSynchronously)
            {
                return;
            }

            if (!(transportResult.AsyncState is AsyncProtocolRequest))
            {
                NetEventSource.Fail(transportResult, "State type is wrong, expected AsyncProtocolRequest.");
            }

            AsyncProtocolRequest asyncRequest = (AsyncProtocolRequest)transportResult.AsyncState;

            try
            {
                NegotiateStream negoStream = (NegotiateStream)asyncRequest.AsyncObject;
                TaskToApm.End(transportResult);
                if (asyncRequest.Count == 0)
                {
                    // This was the last chunk.
                    asyncRequest.Count = -1;
                }

                negoStream.StartWriting(asyncRequest.Buffer, asyncRequest.Offset, asyncRequest.Count, asyncRequest);
            }
            catch (Exception e)
            {
                if (asyncRequest.IsUserCompleted)
                {
                    // This will throw on a worker thread.
                    throw;
                }

                asyncRequest.CompleteUserWithError(e);
            }
        }