private WebLibraryManager() { holdoffUntilKicked = true; // WARNING: this code is executed inside an Instance lock (lock_instance) and should therefor be both minimal and FAST: // hence we push all the work to be done onto a worker thread for processing at a later time. SafeThreadPool.QueueAsyncUserWorkItem(async() => { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); // Whoa! wait until we get *kicked*, for otherwise we MAY try to access libraries which are still // in the process of being *upgraded* via DoUpgrade()! Logging.Info("Waiting for the UPGRADE startup process to finish."); while (holdoffUntilKicked) { if (ShutdownableManager.Instance.IsShuttingDown) { return; } await Task.Delay(250); } Logging.Info("Done waiting for the UPGRADE startup process to finish: going to load the libraries..."); // Look for any web libraries that we know about LoadKnownWebLibraries(KNOWN_WEB_LIBRARIES_FILENAME, only_load_those_libraries_which_are_actually_present: false); // ************************************************************************************************************* // *** MIGRATION TO OPEN SOURCE CODE *************************************************************************** // ************************************************************************************************************* AddLegacyWebLibrariesThatCanBeFoundOnDisk(); // ************************************************************************************************************* AddLocalGuestLibraryIfMissing(); InitAllLoadedLibraries(); ImportManualsIntoLocalGuestLibraryIfMissing(); SaveKnownWebLibraries(); StatusManager.Instance.ClearStatus("LibraryInitialLoad"); // Fire the 'all done' event which signals the UI that the libraries have finally been loaded: FireWebLibrariesChanged(); }); }
// ************************************************************************************************************* private void ImportManualsIntoLocalGuestLibraryIfMissing() { if (Runtime.IsRunningInVisualStudioDesigner) { return; } WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); // Import the Qiqqa manuals in the background, waiting until the library has loaded... SafeThreadPool.QueueAsyncUserWorkItem(async() => { while (!guest_web_library_detail.Xlibrary.LibraryIsLoaded) { if (ShutdownableManager.Instance.IsShuttingDown) { return; } await Task.Delay(500); } QiqqaManualTools.AddManualsToLibrary(guest_web_library_detail); }); }