protected virtual void OnDownloadProgressChanged(DownloadProgressChangedEventArgs args) { Form1._watch.Text = (st.ElapsedMilliseconds / 1000).ToString() + "s"; var totalProgress = (double)_webClients.Sum(client => client.ProgressPercentage) / (double)_webClients.Count; var callArgs = new SegmentAwareProgressChangedEventArgs((int)Math.Round(totalProgress)); if (DownloadProgressChanged != null) { DownloadProgressChanged(this, callArgs); } for (int x = 0; x < 4; x++) { if (_webClients.Count > x) { Form1.progress[x + 1].Value = _webClients[x].ProgressPercentage; } } Form1.progress[0].Value = callArgs.ProgressPercentage; if (args.BytesReceived == 0) { previous = DateTime.Now; last_byte = args.BytesReceived; goto x; } var now = DateTime.Now; var time_diff = now - previous; var byte_diff = args.BytesReceived - last_byte; if (time_diff.Milliseconds != 0 && byte_diff != 0 && byte_diff > 0) { speed = byte_diff * 1000 / time_diff.Milliseconds; speed = speed / 1024; } last_byte = args.BytesReceived; previous = now; x: if (speed < 200) { Form1.speed.Text = speed.ToString() + " KB"; } }
protected virtual void OnDownloadProgressChanged(DownloadProgressChangedEventArgs args) { var totalProgress = (double)_webClients.Sum(client => client.ProgressPercentage) / (double)_webClients.Count; var callArgs = new SegmentAwareProgressChangedEventArgs((int)Math.Round(totalProgress)); if (DownloadProgressChanged != null) DownloadProgressChanged(this, callArgs); }