BitsJob
private static void ManageJobState(string button, BitsJob job) { switch (button) { case "Resume": job.Resume(); break; case "Cancel": job.Cancel(); break; } }
private void RegisterEvents(BitsJob job) { job.OnJobError += (s, e) => { _status.NextVersion = new Version(); _status.BitsJobId = Guid.Empty; _status.Save(); OnUpdateDownloadError(new UpdateErrorEventArgs(e.Error)); job.Cancel(); job.Dispose(); }; job.OnJobTransferred += (s, e) => { job.Complete(); job.Dispose(); OnUpdateDownloaded(new UpdateDownloadedEventArgs()); }; job.OnJobModified += (s, e) => { if (job != null && job.State == JobState.Transferring) { if (job.Progress != null) { OnUpdateDownloadProgressChanged(new UpdateProgressEventArgs(job.Progress.BytesTransferred, job.Progress.BytesTotal)); } } }; }