A small CopyToAsync() extension for C# Streams that features progress monitoring.
Features:
- Reports progress to a user provided IProgress instance.
- Reads new chunks from source stream concurrently to writing the previously read chunks to the destination.
Stream sourceStream;
Stream destinationStream;
IProgress<long> progress = new SomeProgressImplementation();
int bufferSize = 1024; // optional
sourceStream.CopyToAsync(destinationStream, progress, bufferSize);
// continue work while source gets copied to destination and with regular progress reports after each bufferSize bytes