2using System.Threading.Tasks;
13 private long nrReadTotal = 0;
14 private long nrWrittenTotal = 0;
38 public event EventHandlerAsync<IoBytesEventArgs>
OnRead;
43 public event EventHandlerAsync<IoBytesEventArgs>
OnWrite;
46 public override void Write(
byte[] array,
int offset,
int count)
48 base.Write(array, offset, count);
50 this.nrWrittenTotal += count;
55 public override async Task
WriteAsync(
byte[] buffer,
int offset,
int count, CancellationToken cancellationToken)
57 await base.WriteAsync(buffer, offset, count, cancellationToken);
59 this.nrWrittenTotal += count;
60 await this.OnWrite.Raise(
this,
new IoBytesEventArgs(count, this.nrWrittenTotal));
66 base.WriteByte(value);
68 this.nrWrittenTotal++;
73 public override int Read(
byte[] array,
int offset,
int count)
75 int i = base.Read(array, offset, count);
79 this.nrReadTotal += i;
87 public override async Task<int>
ReadAsync(
byte[] buffer,
int offset,
int count, CancellationToken cancellationToken)
89 int i = await base.ReadAsync(buffer, offset, count, cancellationToken);
93 this.nrReadTotal += i;
103 int i = base.ReadByte();
Event arguments for an I/O bytes event.
Class managing the contents of a temporary stream. When the class is disposed, any temporary file is ...
TemporaryProgressStream(int BufferSize)
Class managing the contents of a temporary stream. When the class is disposed, any temporary file is ...
TemporaryProgressStream()
Class managing the contents of a temporary stream. When the class is disposed, any temporary file is ...
override int Read(byte[] array, int offset, int count)
EventHandlerAsync< IoBytesEventArgs > OnRead
Event raised when data has been read from the file.
EventHandlerAsync< IoBytesEventArgs > OnWrite
Event raised when data has been written to the file.
override async Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override void WriteByte(byte value)
override void Write(byte[] array, int offset, int count)
override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...