/// <summary> /// Checks if cancelled. /// </summary> private void CheckIfCancelled(long bytesReadSoFar = 0, long totalBytesToRead = 0) { if (!cancelAsync) { return; } var args = new WebRequestProgressCompletedEventArgs(null, true) { TimeStarted = transferStart, TimeElapsed = DateTime.Now - transferStart, }; if (bytesReadSoFar >= 0) { args.ProcessedBytes = bytesReadSoFar; } if (bytesReadSoFar >= 0) { args.TotalBytes = totalBytesToRead; } OnProgressFailed(args); }
/// <summary> /// Raises the <see cref="E:ProgressFailed" /> event. /// </summary> /// <param name="e">The <see cref="WebRequestProgressChangedEventArgs"/> instance containing the event data.</param> protected virtual void OnProgressFailed(WebRequestProgressCompletedEventArgs e) { var handler = _progressFailed; handler?.Invoke(this, e); }