/// <summary> /// Determines if a NIF file is done pre-loading. Also returns true for cached models that weren't explicitly pre-loaded. Thread-safe. /// </summary> public bool IsDonePreLoading(string filePath) { NIF.NiFile preLoadedFile; lock (dictionariesLock) { if (preLoadedNIFFiles.TryGetValue(filePath, out preLoadedFile)) { return(preLoadedFile != null); } else { return(NIFPrefabs.ContainsKey(filePath)); } } }
/// <summary> /// Pre-load a NIF file asynchronously. /// </summary> public void PreLoadNIFAsync(string filePath) { lock (dictionariesLock) { // If the NIF is already loading or has already loaded, return. if (preLoadedNIFFiles.ContainsKey(filePath) || NIFPrefabs.ContainsKey(filePath)) { return; } // Ensure filePath is a key in the dictionary so that the NIF isn't loaded multiple times. preLoadedNIFFiles[filePath] = null; } var waitCallback = new WaitCallback(PreLoadNIFThreadFunc); if (!ThreadPool.QueueUserWorkItem(waitCallback, filePath)) { throw new Exception("Failed adding the NIF preloading task for the file " + filePath + " to the thread pool."); } }