// // // private static void ReadCallback(IAsyncResult transportResult) { GlobalLog.Assert(transportResult.AsyncState is FixedSizeReader, "ReadCallback|State type is wrong, expected FixedSizeReader."); if (transportResult.CompletedSynchronously) { return; } FixedSizeReader reader = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = reader._Request; // Async completion try { int bytes = reader._Transport.EndRead(transportResult); if (reader.CheckCompletionBeforeNextRead(bytes)) { return; } reader.StartReading(); } catch (Exception e) { if (request.IsUserCompleted) { throw; } request.CompleteWithError(e); } }
private static void ReadCallback(IAsyncResult transportResult) { if (!(transportResult.AsyncState is FixedSizeReader)) { NetEventSource.Fail(null, "State type is wrong, expected FixedSizeReader."); } if (transportResult.CompletedSynchronously) { return; } FixedSizeReader reader = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = reader._request; // Async completion. try { int bytes = reader._transport.EndRead(transportResult); if (reader.CheckCompletionBeforeNextRead(bytes)) { return; } reader.StartReading(); } catch (Exception e) { if (request.IsUserCompleted) { throw; } request.CompleteUserWithError(e); } }
private static void ReadCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { FixedSizeReader asyncState = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = asyncState._Request; try { int bytes = asyncState._Transport.EndRead(transportResult); if (!asyncState.CheckCompletionBeforeNextRead(bytes)) { asyncState.StartReading(); } } catch (Exception exception) { if (request.IsUserCompleted) { throw; } request.CompleteWithError(exception); } } }