Ejemplo n.º 1
0
        private async void SaveSettingsTask(UserSettingsJSON ins)
        {
            while (true)
            {
                if (ins._ConfigChanged)
                {
                    try
                    {
                        logger.Info("Saving settings to disk with {0} at {1}", nameof(UserSettingsJSON), _SettingsFilePath);

                        lock (_CurrentSettingsArray)
                        {
                            if (!Directory.Exists(Path.GetDirectoryName(_SettingsFilePath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(_SettingsFilePath));
                            }

                            File.WriteAllText(_SettingsFilePath, JsonConvert.SerializeObject(_CurrentSettingsArray));
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Debug(ex, "Error when saving settings to disk with {0} at {1}", nameof(UserSettingsJSON), _SettingsFilePath);
                    }
                    ins._ConfigChanged = false;
                }
                await Task.Delay(10000);
            }
        }
Ejemplo n.º 2
0
 static UserSettingsJSON()
 {
     Instance = new UserSettingsJSON();
 }