public async void CBDownloadMadeProgress(object sender, AppCastItem item, ItemDownloadProgressEventArgs e) { await Task.Run(() => { if (LastProgressPercentage != e.ProgressPercentage) { LastProgressPercentage = e.ProgressPercentage; string DownloadLog = string.Format($"The download made some progress! {e.ProgressPercentage}% done."); SparkleInst.LogWriter.PrintMessage(DownloadLog); if (IsCancelRequested == false) { string DownloadInfo = string.Format($"{item.AppName} {item.Version}<br>The download made some progress! {e.ProgressPercentage}% done."); DownloadUpdate?.UpdateProgress(DownloadInfo, e.ProgressPercentage); } else { if (IsCanceled == false) { IsCanceled = true; Task.Delay(100); DownloadUpdate?.ClosePopUp(); } } } }); }
public async void CBFinishedDownloading(AppCastItem item, string path) { await Task.Run(() => { if (IsCancelRequested == false) { string DownloadLog = string.Format($"{item.AppName} {item.Version} Done downloading! : [{path}]"); string DownloadInfo = string.Format($"{item.AppName} {item.Version}<br>Done downloading!"); SparkleInst.LogWriter.PrintMessage(DownloadLog); DownloadUpdate?.UpdateProgress(DownloadInfo, 100); Task.Delay(1000); DownloadUpdate?.ClosePopUp(); DownloadPath = path; string FinishedDownloadInfo = string.Format($"{item.AppName} {item.Version}"); FinishedDownload?.OpenPopUp(FinishedDownloadInfo); } else { string DownloadLog = string.Format($"{item.AppName} {item.Version} Force Cancel downloading! : [{path}]"); SparkleInst.LogWriter.PrintMessage(DownloadLog); string DownloadInfo = string.Format($"{item.AppName} {item.Version}<br>Cancel downloading!"); DownloadUpdate?.UpdateProgress(DownloadInfo, 100); Task.Delay(1000); if (IsCanceled == false) { IsCancelRequested = false; IsCanceled = true; DownloadUpdate?.ClosePopUp(); File.Delete(path); } } }); }