コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }