void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
lock (locker)
{
if (DownloadProgressChanged != null)
{
int speed = 0;
DateTime current = DateTime.Now;
TimeSpan interval = current - lastNotificationTime;
if (interval.TotalSeconds < 60)
{
speed = (int)Math.Floor((this.DownloadedSize + this.CachedSize-
this.lastNotificationDownloadedSize) / interval.TotalSeconds);
}
lastNotificationTime = current;
lastNotificationDownloadedSize = this.DownloadedSize + this.CachedSize;
var downloadProgressChangedEventArgs =
new DownloadProgressChangedEventArgs(
DownloadedSize, TotalSize, speed);
this.OnDownloadProgressChanged(downloadProgressChangedEventArgs);
}
}
}