private void EndRead(IAsyncResult ar, CommandStreams state) { var read = state.StreamReader.EndRead(ar); if (read > 0) { state.StreamWriter.BeginWrite(state.Buffer, 0, read, __EndWrite, state); } else { CommandThreads.Run(() => Completing(state)); } }
private void Completing(CommandStreams state) { try { var ms = state.StreamWriter as MemoryStream; if (ms != null) { Result = Je.bin.MemToObj <T>(ms, _encoding); } state.Dispose(); EndExecuteEvent(Je.cmd.EmptyEventArgs(this)); } catch (Exception e) { state.Dispose(); Finalize(e); } }
private void EndWrite(IAsyncResult ar, CommandStreams state) { state.StreamWriter.EndWrite(ar); state.Reset(); state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndRead, state); }