public void Dispose()
        {
            lock (sync) {
                if (manager != null)
                {
                    manager.Group.Started         -= OnManagerStartedHandler;
                    manager.Group.Stopped         -= OnManagerStoppedHandler;
                    manager.Group.ProgressChanged -= OnManagerProgressChangedHandler;
                    manager.Group.StatusChanged   -= OnManagerStatusChangedHandler;

                    manager = null;
                }
            }

            Gtk.Application.Invoke(delegate {
                lock (sync) {
                    if (downloadJob != null)
                    {
                        downloadJob.CancelRequested -= OnCancelRequested;
                        downloadJob.Finish();
                        downloadJob = null;
                        //SourceManager.RemoveSource (downloadSource);
                        //downloadSource = null;
                    }
                }
            });
        }
 private void OnManagerStoppedHandler(object sender, EventArgs e)
 {
     Gtk.Application.Invoke(delegate {
         lock (sync) {
             if (downloadJob != null)
             {
                 downloadJob.CancelRequested -= OnCancelRequested;
                 downloadJob.Finish();
                 downloadJob = null;
                 //SourceManager.RemoveSource (downloadSource);
             }
         }
     });
 }
        private void OnManagerStartedHandler(object sender, EventArgs e)
        {
            Gtk.Application.Invoke(delegate {
                lock (sync) {
                    if (downloadJob == null)
                    {
                        //SourceManager.AddSource (downloadSource);

                        downloadJob = new DownloadUserJob();
                        downloadJob.CancelRequested += OnCancelRequested;
                        downloadJob.Register();
                    }
                }
            });
        }
        public void Dispose()
        {
            lock (sync) {
                if (manager != null) {
                    manager.Group.Started -= OnManagerStartedHandler;
                    manager.Group.Stopped -= OnManagerStoppedHandler;
                    manager.Group.ProgressChanged -= OnManagerProgressChangedHandler;
                    manager.Group.StatusChanged -= OnManagerStatusChangedHandler;

                    manager = null;
                }
            }

            Gtk.Application.Invoke (delegate {
                lock (sync) {
                    if (downloadJob != null) {
                        downloadJob.CancelRequested -= OnCancelRequested;
                        downloadJob.Finish ();
                        downloadJob = null;
                        //SourceManager.RemoveSource (downloadSource);
                        //downloadSource = null;
                    }
                }
            });
        }
 private void OnManagerStoppedHandler(object sender, EventArgs e)
 {
     Gtk.Application.Invoke (delegate {
         lock (sync) {
             if (downloadJob != null) {
                 downloadJob.CancelRequested -= OnCancelRequested;
                 downloadJob.Finish ();
                 downloadJob = null;
                 //SourceManager.RemoveSource (downloadSource);
             }
         }
     });
 }
        private void OnManagerStartedHandler(object sender, EventArgs e)
        {
            Gtk.Application.Invoke (delegate {
                lock (sync) {
                    if (downloadJob == null) {
                        //SourceManager.AddSource (downloadSource);

                        downloadJob = new DownloadUserJob ();
                        downloadJob.CancelRequested += OnCancelRequested;
                        downloadJob.Register ();
                    }
                }
            });
        }