// forced pull internal bool ForcePull() { var download = new ClientDownload(new Guid().ToString("D"), Program.License.User, Program.License.Password); //download.FastPull(); var bytes = download.PullZip(); if (bytes == null || bytes.Length == 0) { throw new Exception("Pull failed. Try later."); } Program.Start.PullBytes = bytes; if (IsTaskCanceled) { _failed = true; _TerminatePull(download); return(false); } if (download.IsDenied) { _failed = true; Common.ShowNotification("Pull has been denied."); _TerminatePull(download); return(false); } return(_TerminatePull(download)); }
// execute on total completion - when download of both files is finished with success private bool _TerminatePull(ClientDownload download) { var saved = false; if (!_failed && download.IsDownloadCompleted) { Extract(download.PullBytes); saved = true; } PullTerminated?.Invoke(this, new EventArgs()); return(saved); }
private void StartPull() { Task.Factory.StartNew(() => { try { var clientDownload = new ClientDownload(new Guid().ToString("D"), Program.License.User, Program.License.Password); PullBytes = clientDownload.PullZip(); } catch (Exception ex) { PullException = ex; } }); }