예제 #1
0
        private async void Download()
        {
            string filename;

            try {
                _log.Debug("Downloading update");
                ProgressText = "Downloading package from\n" + _releaseInfo.DownloadUrl;
                filename     = await _updateManager.DownloadReleaseAsync(
                    _releaseInfo,
                    progress => {
                    Progress            = progress;
                    IsPreparingDownload = false;
                },
                    _cancellationTokenSource.Token);
            } catch (WebException ex) {
                if (ex.Status != WebExceptionStatus.RequestCanceled)
                {
                    _log.ErrorException("Error downloading release from " + _releaseInfo.DownloadUrl, ex);
                }
                filename = null;
            }
            if (filename != null && File.Exists(filename))
            {
                _log.Debug("Downloading succeeded, spawning");
                Process.Start(filename);
                Close(true);
            }
            else
            {
                _log.Debug("Download failed or cancelled");
                Close(false);
            }
        }