Class ProgressStream
Decorator that adds progress-tracking and cancellation to another Stream.
Inheritance
ProgressStream
Assembly: NanoByte.Common.dll
Syntax
public sealed class ProgressStream : DelegatingStream
Constructors
ProgressStream(Stream, IProgress<Int64>, CancellationToken)
Decorator that adds progress-tracking and cancellation to another Stream.
Declaration
public ProgressStream(Stream underlyingStream, IProgress<long> progress = null, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
Stream |
underlyingStream |
Underlying stream to delegate to. Will be disposed together with this stream.
|
IProgress<Int64> |
progress |
Used to report back the number of bytes that have been read or written.
|
CancellationToken |
cancellationToken |
Used to signal when the user wants to cancel the stream. If signaled read an write requests will start throwing OperationCanceledException.
|
Properties
Length
The length of the underlying stream if CanSeek is true
. Otherwise, the number of bytes read or written so far.
This value can also be overriden by SetLength(Int64).
Declaration
public override long Length { get; }
Property Value
Overrides
Methods
Read(Byte[], Int32, Int32)
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
buffer |
|
Int32 |
offset |
|
Int32 |
count |
|
Returns
Overrides
Read(Span<Byte>)
Declaration
public override int Read(Span<byte> buffer)
Parameters
Type |
Name |
Description |
Span<System.Byte> |
buffer |
|
Returns
Overrides
ReadAsync(Byte[], Int32, Int32, CancellationToken)
Declaration
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken ct)
Parameters
Returns
Overrides
ReadAsync(Memory<Byte>, CancellationToken)
Declaration
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken ct = null)
Parameters
Returns
Overrides
SetLength(Int64)
Overrides the value returned by Length. Does not affect the underlying stream.
Declaration
public override void SetLength(long value)
Parameters
Type |
Name |
Description |
Int64 |
value |
|
Overrides
Write(Byte[], Int32, Int32)
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
buffer |
|
Int32 |
offset |
|
Int32 |
count |
|
Overrides
Write(ReadOnlySpan<Byte>)
Declaration
public override void Write(ReadOnlySpan<byte> buffer)
Parameters
Overrides
WriteAsync(Byte[], Int32, Int32, CancellationToken)
Declaration
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken ct)
Parameters
Returns
Overrides
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)
Declaration
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken ct = null)
Parameters
Returns
Overrides
Extension Methods