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); } } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { //TODO: release COM resource this.fileList = null; } } disposed = true; }
public BitsFiles EnumFiles() { try { IEnumBackgroundCopyFiles fileList = null; this.job.EnumFiles(out fileList); this.files = new BitsFiles(this, fileList); } catch (COMException exception) { manager.PublishException(this, exception); } return(this.files); }
public MsBitsFiles(IEnumBackgroundCopyFiles files) : base(() => files.Reset(), () => { IBackgroundCopyFile file = null; uint fetched = 0; files.Next(1, out file, out fetched); return(fetched == 1 ? file : null); }, () => { uint count; files.GetCount(out count); return((int)count); }) { }
/// <summary>Releases unmanaged and - optionally - managed resources.</summary> /// <param name="disposing"><c>True</c> to release both managed and unmanaged resources; otherwise, <c>False</c> to release only unmanaged resources.</param> void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { // TODO: release COM resource this.fileList = null; if (this.job != null) { this.job.Dispose(); } } } this.disposed = true; }
/// <summary>Disposes of the Enumerator object.</summary> public void Dispose() { ienum = null; icurrentfile = null; }
internal Enumerator(IEnumBackgroundCopyFiles enumfiles) { ienum = enumfiles; ienum.Reset(); }
internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList) { this.fileList = fileList; this.job = job; this.Refresh(); }