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 CBDownloadError(AppCastItem item, string path, Exception exception) { // Display in progress when error occured -> DownloadInfo.Text = "We had an error during the download process :( -- " + exception.Message; await Task.Run(() => { string DownloadLog = string.Format($"{item.AppName} {item.Version}, We had an error during the download process :( -- {exception.Message}"); CLog.Here().Error(DownloadLog); DownloadUpdate?.ClosePopUp(); File.Delete(path); IsCancelRequested = false; IsCanceled = false; }); }
public async void CBDownloadCanceled(AppCastItem item, string path) { await Task.Run(() => { CLog.Here().Information($"AppUpdaterService - CBDownloadCanceled : [ {item.AppName} {item.Version} Cancel downloading! : [{path}] ]"); if (IsCanceled == false) { IsCancelRequested = false; IsCanceled = true; 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); } } }); }