in JetBrains.Profiler.SelfApi/src/Impl/PrerequisiteBase.cs [322:346]
private static void CopyStream(
[NotNull] Stream from,
[NotNull] Stream to,
long estimatedLength,
[NotNull] IProgress<double> progress,
CancellationToken cancellationToken)
{
var buffer = new byte[64 * 1024];
var bytesCopied = 0L;
while (true)
{
var bytesRead = from.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
break;
to.Write(buffer, 0, bytesRead);
bytesCopied += bytesRead;
var percents = bytesCopied < estimatedLength ? bytesCopied * 100.0 / estimatedLength : 100;
progress.Report(percents);
cancellationToken.ThrowIfCancellationRequested();
}
}