public void CopyTo(ProcessWriter writer, CancellationToken cancellationToken) { Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from channel {0} with {1} byte buffer.", this.Stream.ChannelHandle, BUFFER_SIZE); var length = default(int); var buffer = new byte[BUFFER_SIZE]; while ((length = Bass.ChannelGetData(this.Stream.ChannelHandle, buffer, BUFFER_SIZE)) > 0) { if (cancellationToken.IsCancellationRequested) { break; } writer.Write(buffer, length); this.Update(); } Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from channel {0}, closing process input.", this.Stream.ChannelHandle); writer.Close(); }
public void CopyTo(ProcessWriter writer, CancellationToken cancellationToken) { Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from process {0} with {1} byte buffer.", this.Process.Id, BUFFER_SIZE); var length = default(int); var buffer = new byte[BUFFER_SIZE]; while (!this.Process.HasExited) { if (cancellationToken.IsCancellationRequested) { break; } while ((length = this.Process.StandardOutput.BaseStream.Read(buffer, 0, BUFFER_SIZE)) > 0) { if (cancellationToken.IsCancellationRequested) { break; } writer.Write(buffer, length); } } Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from process {0}, closing process input.", this.Process.Id); writer.Close(); }