Did you try to copy the stream in pieces, and each time you check the chunk, check if a cancellation has been set, or a cancellation token has been registered?
For example, you can do something like:
void CopyStream(Stream inputStream, Stream outputStream) { var buffer = new byte[1024]; int bytesRead; while((bytesRead = inputStream.Read(buffer, 0, buffer.Length)) > 0) { outputStream.Write(buffer, 0, bytesRead); if(cancelled){
source share