private async Task UncheckedInstall(Package currentPackage, LogHandler logCallback, ProgressHandler progressCallback) { EventHandler <ProgressReport> progressHandler = (object sender, ProgressReport e) => { progressCallback(null, null, e.Progress); logCallback(LogLevel.Verbose, string.Format("Extracted {0}", e.CurrentFile)); }; EventHandler <ProblemReport> problemHandler = (object sender, ProblemReport e) => { throw e.Exception; }; Manipulation.ProgressChanged += progressHandler; Manipulation.ProblemReport += problemHandler; try { await Task.Run(delegate { string ExtractionDirectory; switch (currentPackage.PackageType) { case PackageType.Route: ExtractionDirectory = RouteInstallationDirectory; break; case PackageType.Train: ExtractionDirectory = TrainInstallationDirectory; break; case PackageType.Loksim3D: ExtractionDirectory = LoksimPackageInstallationDirectory; break; default: ExtractionDirectory = OtherInstallationDirectory; break; } string PackageFiles = ""; Manipulation.ExtractPackage(currentPackage, ExtractionDirectory, currentDatabaseFolder, ref PackageFiles); if (PackageFiles != string.Empty) { switch (currentPackage.PackageType) { case PackageType.Route: for (int i = Database.currentDatabase.InstalledRoutes.Count; i > 0; i--) { if (Database.currentDatabase.InstalledRoutes[i - 1].GUID == currentPackage.GUID) { Database.currentDatabase.InstalledRoutes.Remove(Database.currentDatabase.InstalledRoutes[i - 1]); } } Database.currentDatabase.InstalledRoutes.Add(currentPackage); break; case PackageType.Train: for (int i = Database.currentDatabase.InstalledTrains.Count; i > 0; i--) { if (Database.currentDatabase.InstalledTrains[i - 1].GUID == currentPackage.GUID) { Database.currentDatabase.InstalledTrains.Remove(Database.currentDatabase.InstalledTrains[i - 1]); } } Database.currentDatabase.InstalledTrains.Add(currentPackage); break; default: for (int i = Database.currentDatabase.InstalledOther.Count; i > 0; i--) { if (Database.currentDatabase.InstalledOther[i - 1].GUID == currentPackage.GUID) { Database.currentDatabase.InstalledOther.Remove(Database.currentDatabase.InstalledOther[i - 1]); } } Database.currentDatabase.InstalledOther.Add(currentPackage); break; } } }); } finally { Manipulation.ProgressChanged -= progressHandler; Manipulation.ProblemReport -= problemHandler; } Database.SaveDatabase(); }