internal DownloadJob(Guid id, IBackgroundCopyJob bitsJob) { this.id = id; string name; bitsJob.GetDisplayName(out name); DisplayName = name; string description; bitsJob.GetDescription(out description); Description = description; BG_JOB_PRIORITY priority; bitsJob.GetPriority(out priority); Priority = (DownloadPriority)(int)priority; bitsJob.GetMinimumRetryDelay(out minimumRetryDelay); bitsJob.GetNoProgressTimeout(out noProgressTimeout); BG_JOB_STATE state; bitsJob.GetState(out state); Status = (DownloadStatus)(int)state; _BG_JOB_PROGRESS progress; bitsJob.GetProgress(out progress); BytesTotal = progress.BytesTotal; BytesTransferred = progress.BytesTransferred; bitsJob.SetNotifyInterface(this); IEnumBackgroundCopyFiles enumFiles = null; try { bitsJob.EnumFiles(out enumFiles); uint fetched; IBackgroundCopyFile file; enumFiles.Next(1, out file, out fetched); if (fetched == 1) { string remoteUrl; file.GetRemoteName(out remoteUrl); RemoteUrl = remoteUrl; string localName; file.GetLocalName(out localName); LocalFile = localName; } } finally { if (enumFiles != null) { Marshal.ReleaseComObject(enumFiles); } } }
/// <summary> /// Method called by BITS when the job is modified, this method is used to notify progress. /// </summary> /// <param name="task">The DownloadTask instance.</param> /// <param name="pJob">The BITS job reference.</param> private void OnJobModification(DownloadTask task, IBackgroundCopyJob pJob) { BG_JOB_PROGRESS progress; pJob.GetProgress(out progress); var args = new DownloadTaskProgressEventArgs((long)progress.BytesTotal, (long)progress.BytesTransferred, (int)progress.FilesTotal, (int)progress.FilesTransferred, task); OnDownloadProgress(args); }
void IBackgroundCopyCallback.JobModification(IBackgroundCopyJob bitsJob, uint reserved) { _BG_JOB_PROGRESS progress; bitsJob.GetProgress(out progress); BytesTotal = progress.BytesTotal; BytesTransferred = progress.BytesTransferred; BG_JOB_STATE state; bitsJob.GetState(out state); Status = (DownloadStatus)(int)state; }
private void RefreshJobProperties( ) { _job.GetDisplayName(out _displayName); _job.GetDescription(out _description); _BG_JOB_PROGRESS jobProgress; _job.GetProgress(out jobProgress); _bytesTotal = jobProgress.BytesTotal; _bytesTransferred = jobProgress.BytesTransferred; BG_JOB_STATE jobState; _job.GetState(out jobState); this.JobStateDescription = Enum.GetName(jobState.GetType(), jobState); }