コード例 #1
0
        private static void StoreLoadWorkerLoop()
        {
            while (true)
            {
                storeLoadTaskWaitHandle.WaitOne(100);

                lock (storeLoadTaskLock)
                {
                    if (isDisposed)
                    {
                        return;
                    }

                    if (storeLoadTaskStopWatch.Elapsed.TotalMilliseconds > storeLoadTaskTimeToWait)
                    {
                        if (currentStoreLoadTask == StoreLoadTask.LOAD)
                        {
                            if (TryLoadSettings())
                            {
                                currentStoreLoadTask = StoreLoadTask.NONE;
                                System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => ((MainWindow)System.Windows.Application.Current.MainWindow)?.RefreshConfigTabs()));
                            }
                        }
                        else if (currentStoreLoadTask == StoreLoadTask.STORE)
                        {
                            if (TryStoreSettings())
                            {
                                currentStoreLoadTask = StoreLoadTask.NONE;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 private static void DelayedStoreSettings()
 {
     lock (storeLoadTaskLock)
     {
         // wait a full second before storing (that way changing multiple settings won't result in lots of stores, every change will push the time further, the file is stored 1 second after the last change)
         storeLoadTaskTimeToWait = 1000;
         storeLoadTaskStopWatch  = Stopwatch.StartNew();
         currentStoreLoadTask    = StoreLoadTask.STORE;
     }
     storeLoadTaskWaitHandle.Set();
 }
コード例 #3
0
 private static void DelayedLoadSettings()
 {
     lock (storeLoadTaskLock)
     {
         // we only wait 100ms when loading
         storeLoadTaskTimeToWait = 100;
         storeLoadTaskStopWatch  = Stopwatch.StartNew();
         currentStoreLoadTask    = StoreLoadTask.LOAD;
     }
     storeLoadTaskWaitHandle.Set();
 }
コード例 #4
0
        private static void StoreLoadWorkerLoop()
        {
            while (true)
            {
                storeLoadTaskWaitHandle.WaitOne(100);

                lock (storeLoadTaskLock)
                {
                    if (isDisposed)
                    {
                        return;
                    }

                    if (storeLoadTaskStopWatch.Elapsed.TotalMilliseconds > storeLoadTaskTimeToWait)
                    {
                        if (currentModStoreLoadTask == StoreLoadTask.LOAD)
                        {
                            if (TryLoadSettings(HLVRPaths.VRModSettingsFile))
                            {
                                currentModStoreLoadTask = StoreLoadTask.NONE;
                                Application.Current?.Dispatcher?.BeginInvoke((Action)(() => (Application.Current?.MainWindow as MainWindow)?.RefreshConfigTabs(true, false)));
                            }
                        }
                        else if (currentModStoreLoadTask == StoreLoadTask.STORE)
                        {
                            if (TryStoreSettings(ModSettings, HLVRPaths.VRModSettingsFile))
                            {
                                currentModStoreLoadTask = StoreLoadTask.NONE;
                            }
                        }

                        if (currentLauncherStoreLoadTask == StoreLoadTask.LOAD)
                        {
                            if (TryLoadSettings(HLVRPaths.VRLauncherSettingsFile))
                            {
                                currentLauncherStoreLoadTask = StoreLoadTask.NONE;
                                Application.Current?.Dispatcher?.BeginInvoke((Action)(() => (Application.Current?.MainWindow as MainWindow)?.RefreshConfigTabs(false, true)));
                            }
                        }
                        else if (currentLauncherStoreLoadTask == StoreLoadTask.STORE)
                        {
                            if (TryStoreSettings(LauncherSettings, HLVRPaths.VRLauncherSettingsFile))
                            {
                                currentLauncherStoreLoadTask = StoreLoadTask.NONE;
                                Application.Current?.Dispatcher?.BeginInvoke((Action)(() => (Application.Current?.MainWindow as MainWindow)?.RefreshConfigTabs(true, true)));
                            }
                        }
                    }
                }
            }
        }