예제 #1
0
        public static async Task CopyToObserveOnProgressAsync(this Stream stream, Stream destination, int bufferSize,
                                                              IObserver <long> progressChangedWatcher, int step)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (bufferSize <= 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(bufferSize)} must >= 0.");
            }
            if (progressChangedWatcher == null)
            {
                throw new ArgumentNullException(nameof(progressChangedWatcher));
            }
            if (step <= 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(step)} must > 0.");
            }

            var copyer = new StreamCopyProgressObserver(stream, destination, bufferSize, progressChangedWatcher, step);
            await copyer.StartAsync();
        }
예제 #2
0
        public static async Task CopyToObserveOnProgressAsync(this Stream stream, Stream destination, int bufferSize,
            IObserver<long> progressChangedWatcher, int step)
        {
            if (stream == null) throw new ArgumentNullException(nameof(stream));
            if (destination == null) throw new ArgumentNullException(nameof(destination));
            if (bufferSize <= 0) throw new ArgumentOutOfRangeException($"{nameof(bufferSize)} must >= 0.");
            if (progressChangedWatcher == null) throw new ArgumentNullException(nameof(progressChangedWatcher));
            if (step <= 0) throw new ArgumentOutOfRangeException($"{nameof(step)} must > 0.");

            var copyer = new StreamCopyProgressObserver(stream, destination, bufferSize, progressChangedWatcher, step);
            await copyer.StartAsync();
        }