public BitsManager() { // Set threading apartment System.Threading.Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA); int hResult = NativeMethods.CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero, IntPtr.Zero, RpcAuthnLevel.Connect, RpcImpLevel.Impersonate, IntPtr.Zero, EoAuthnCap.None, IntPtr.Zero); this.manager = new BackgroundCopyManager() as IBackgroundCopyManager; this.jobs = new BitsJobs(this); // will be set correctly later after initialization this.notificationHandler = new BitsNotification(this); this.notificationHandler.OnJobErrorEvent += new EventHandler <ErrorNotificationEventArgs>(notificationHandler_OnJobErrorEvent); this.notificationHandler.OnJobModifiedEvent += new EventHandler <NotificationEventArgs>(notificationHandler_OnJobModifiedEvent); this.notificationHandler.OnJobTransferredEvent += new EventHandler <NotificationEventArgs>(notificationHandler_OnJobTransferredEvent); }
public BitsJobs EnumJobs(JobOwner jobOwner) { currentOwner = jobOwner; IEnumBackgroundCopyJobs jobList = null; this.manager.EnumJobs((UInt32)jobOwner, out jobList); if (this.jobs == null) { this.jobs = new BitsJobs(this, jobList); } else { this.jobs.Update(jobList); } return(this.jobs); }