Example #1
0
 /// <summary>
 /// Raises the ProgressChanged event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnProgressChanged(WebHelperProgressChangedEventArgs e)
 {
     if (Options.ReportProgress != null)
     {
         Options.ReportProgress(this, e.BytesSent, e.BytesToSend, e.BytesReceived, e.BytesToReceive);
     }
     if (ProgressChanged == null)
     {
         return;
     }
     ProgressChanged(this, e);
 }
Example #2
0
        public void ReportResponseProgress(long bytesRead)
        {
            var pct = (int)(((double)bytesRead / mResponseContentLength) * 100);

            if (mLastResPct != pct)
            {
                // Only raise the progress changed event if the progress percent changed. It can become a performance issue if you raise it every time you write a few bytes.
                var progressArgs = new WebHelperProgressChangedEventArgs(mRequestContentLength, mRequestContentLength, mResponseContentLength, bytesRead, Options.State);
                Post((arg) =>
                {
                    OnProgressChanged((WebHelperProgressChangedEventArgs)arg);
                }, progressArgs);
                mLastResPct = pct;
            }
        }