Exemple #1
0
 protected virtual void OnDownloadFinished(DownloadEventArgs e)
 {
     if (Finished == false)
     {
         Finished = true;
         FinishedDownload?.Invoke(this, e);
     }
 }
        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);
                    }
                }
            });
        }
 protected virtual void OnDownloadFinished(DownloadEventArgs e)
 {
     process.OutputDataReceived -= DownloadOutputHandler;
     process.ErrorDataReceived  -= DownloadErrorDataReceived;
     FinishedDownload?.Invoke(this, e);
 }