// // Assuming InnerStream type == typeof(NetworkStream) // private static void MulitpleWriteCallback(IAsyncResult transportResult) { if (transportResult.CompletedSynchronously) { return; } GlobalLog.Assert(transportResult.AsyncState is AsyncProtocolRequest, "SslStream::MulitpleWriteCallback|State type is wrong, expected AsyncProtocolRequest."); SplitWriteAsyncProtocolRequest asyncRequest = (SplitWriteAsyncProtocolRequest)transportResult.AsyncState; _SslStream sslStream = (_SslStream)asyncRequest.AsyncObject; try { ((NetworkStream)(sslStream._SslState.InnerStream)).EndMultipleWrite(transportResult); sslStream._SslState.FinishWrite(); sslStream.StartWriting(asyncRequest.SplitWritesState, asyncRequest); } catch (Exception e) { if (asyncRequest.IsUserCompleted) { // This will throw on a worker thread. throw; } sslStream._SslState.FinishWrite(); asyncRequest.CompleteWithError(e); } }
private static void WriteCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { AsyncProtocolRequest asyncState = (AsyncProtocolRequest)transportResult.AsyncState; _SslStream asyncObject = (_SslStream)asyncState.AsyncObject; try { asyncObject._SslState.InnerStream.EndWrite(transportResult); asyncObject._SslState.FinishWrite(); if (asyncState.Count == 0) { asyncState.Count = -1; } asyncObject.StartWriting(asyncState.Buffer, asyncState.Offset, asyncState.Count, asyncState); } catch (Exception exception) { if (asyncState.IsUserCompleted) { throw; } asyncObject._SslState.FinishWrite(); asyncState.CompleteWithError(exception); } } }
// // // private static void WriteCallback(IAsyncResult transportResult) { if (transportResult.CompletedSynchronously) { return; } GlobalLog.Assert(transportResult.AsyncState is AsyncProtocolRequest, "SslStream::WriteCallback|State type is wrong, expected AsyncProtocolRequest."); AsyncProtocolRequest asyncRequest = (AsyncProtocolRequest)transportResult.AsyncState; _SslStream sslStream = (_SslStream)asyncRequest.AsyncObject; try { sslStream._SslState.InnerStream.EndWrite(transportResult); sslStream._SslState.FinishWrite(); if (asyncRequest.Count == 0) { // this was the last chunk asyncRequest.Count = -1; } sslStream.StartWriting(asyncRequest.Buffer, asyncRequest.Offset, asyncRequest.Count, asyncRequest); } catch (Exception e) { if (asyncRequest.IsUserCompleted) { // This will throw on a worker thread. throw; } sslStream._SslState.FinishWrite(); asyncRequest.CompleteWithError(e); } }
private static void MulitpleWriteCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { SplitWriteAsyncProtocolRequest asyncState = (SplitWriteAsyncProtocolRequest)transportResult.AsyncState; _SslStream asyncObject = (_SslStream)asyncState.AsyncObject; try { ((NetworkStream)asyncObject._SslState.InnerStream).EndMultipleWrite(transportResult); asyncObject._SslState.FinishWrite(); asyncObject.StartWriting(asyncState.SplitWritesState, asyncState); } catch (Exception exception) { if (asyncState.IsUserCompleted) { throw; } asyncObject._SslState.FinishWrite(); asyncState.CompleteWithError(exception); } } }