Example #1
0
        void client_DownloadProgressChanged(object sender, DownloadEventArgs.DownloadProgressChangedEventArgs e)
        {
            lock (locker)
            {
                int      speed    = 0;
                DateTime current  = DateTime.Now;
                TimeSpan interval = current - lastNotificationTime;

                if (interval.TotalSeconds < 60)
                {
                    speed = (int)Math.Floor((DownloadedSize + CachedSize - lastNotificationDownloadedSize) / interval.TotalSeconds);
                    Speed = speed;
                }


                lastNotificationTime           = current;
                lastNotificationDownloadedSize = DownloadedSize + CachedSize;

                var downloadProgressChangedEventArgs = new DownloadEventArgs.DownloadProgressChangedEventArgs(DownloadedSize, TotalSize, speed);

                UpgradeProperties();
            }
        }
 protected virtual void OnDownloadProgressChanged(DownloadEventArgs.DownloadProgressChangedEventArgs e)
 {
     DownloadProgressChanged?.Invoke(this, e);
 }