public void StartDownload(GUIMod module) { if (module == null || !module.IsCKAN) { return; } Main.Instance.ShowWaitDialog(false); if (cacheWorker.IsBusy) { Task.Factory.StartNew(() => { // Just pass to the existing worker downloader.DownloadModules(new List <CkanModule> { module.ToCkanModule() }); module.UpdateIsCached(); }); } else { // Start up a new worker downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache); cacheWorker.RunWorkerAsync(module); } }
private void _PostModCaching(GUIMod module) { module.UpdateIsCached(); Main.Instance.HideWaitDialog(true); // User might have selected another row. Show current in tree. UpdateModContentsTree(SelectedModule.ToCkanModule(), true); }
public void StartDownload(GUIMod module) { if (module == null || !module.IsCKAN) { return; } if (cacheWorker == null) { cacheWorker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true, }; cacheWorker.DoWork += CacheMod; cacheWorker.RunWorkerCompleted += PostModCaching; } Main.Instance.ShowWaitDialog(false); if (cacheWorker.IsBusy) { Task.Factory.StartNew(() => { // Just pass to the existing worker downloader.DownloadModules(new List <CkanModule> { module.ToCkanModule() }); module.UpdateIsCached(); }); } else { // Start up a new worker downloader = new NetAsyncModulesDownloader(Main.Instance.currentUser, Main.Instance.Manager.Cache); cacheWorker.RunWorkerAsync(module); } }