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)); } } }; }
private void ctxmiComplete_Click(object sender, EventArgs e) { if (this.lvJobList.SelectedItems.Count == 1) { JobWrapper tag = this.lvJobList.SelectedItems[0].Tag as JobWrapper; BitsJob bitsJob = tag.BitsJob; if ((((bitsJob.JobType == JobType.Download) && (bitsJob.State != JobState.Acknowledged)) && (bitsJob.State != JobState.Canceled)) || ((bitsJob.JobType == JobType.Upload) && (bitsJob.State == JobState.Transferred))) { bitsJob.Complete(); } this.ControlsFromJobState(); } }