Пример #1
0
        /// <summary>
        /// Handle the DownloadProgressChanged event of all the HttpDownloadClients, and
        /// calculate the download speed.
        /// </summary>
        void client_DownloadProgressChanged(object sender, HttpDownloadClientProgressChangedEventArgs e)
        {
            lock (locker)
            {
                DownloadedSize += e.Size;
                bufferCount++;

                if (bufferCount == BufferCountPerNotification)
                {
                    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.lastNotificationDownloadedSize) / interval.TotalSeconds);
                        }

                        lastNotificationTime           = current;
                        lastNotificationDownloadedSize = this.DownloadedSize;

                        var downloadProgressChangedEventArgs =
                            new MultiThreadedWebDownloaderProgressChangedEventArgs(
                                DownloadedSize, TotalSize, speed);
                        this.OnDownloadProgressChanged(downloadProgressChangedEventArgs);
                    }

                    // Reset the bufferCount.
                    bufferCount = 0;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Raise the DownloadProgressChanged event.
 /// </summary>
 protected virtual void OnDownloadProgressChanged(HttpDownloadClientProgressChangedEventArgs e)
 {
     if (DownloadProgressChanged != null)
     {
         DownloadProgressChanged(this, e);
     }
 }
Пример #3
0
 /// <summary>
 /// Raise the DownloadProgressChanged event.
 /// </summary>
 protected virtual void OnDownloadProgressChanged(HttpDownloadClientProgressChangedEventArgs e)
 {
     if (DownloadProgressChanged != null)
     {
         DownloadProgressChanged(this, e);
     }
 }
        /// <summary>
        /// Handle the DownloadProgressChanged event of all the HttpDownloadClients, and 
        /// calculate the download speed.
        /// </summary>
        void client_DownloadProgressChanged(object sender, HttpDownloadClientProgressChangedEventArgs e)
        {
            lock (locker)
            {
                DownloadedSize += e.Size;
                bufferCount++;

                if (bufferCount == BufferCountPerNotification)
                {
                    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.lastNotificationDownloadedSize) / interval.TotalSeconds);
                        }

                        lastNotificationTime = current;
                        lastNotificationDownloadedSize = this.DownloadedSize;

                        var downloadProgressChangedEventArgs =
                            new MultiThreadedWebDownloaderProgressChangedEventArgs(
                                DownloadedSize, TotalSize, speed);
                        this.OnDownloadProgressChanged(downloadProgressChangedEventArgs);

                    }

                    // Reset the bufferCount.
                    bufferCount = 0;
                }

            }
        }