private void DownloadTask_StatusUpdate(double progressPercentage, long bps, DownloadTask.Status status) { try { Dispatcher.Invoke(new Action(() => { InfoBox.Foreground = new SolidColorBrush(Color.FromRgb(0x00, 0x00, 0x00)); switch (status) { case DownloadTask.Status.Downloading: InfoBox.Text = string.Format("{0:0.0}% {1} 下载中...", progressPercentage, FormatBps(bps)); break; case DownloadTask.Status.Analyzing: InfoBox.Text = "正在获取下载地址..."; break; case DownloadTask.Status.Merging: InfoBox.Text = "正在完成..."; break; case DownloadTask.Status.Finished: InfoBox.Text = "下载完成!!!"; break; } PBar.Value = progressPercentage; })); } catch (TaskCanceledException) { } }
private static void DownloadTask_StatusUpdate(DownloadTask downloadTask, double progressPercentage, long bps, DownloadTask.Status statues) { Console.WriteLine("{0} {1} {2}", downloadTask.Title, progressPercentage, statues); }