Beispiel #1
0
 public async Task ClearLog()
 {
     _messages.Clear();
     using (await _fileLock.EnterAsync())
         if (_file.Exists && _file.Length > 0)
         {
             File.WriteAllText(_file.FullName, string.Empty);
         }
 }
Beispiel #2
0
        public async ValueTask Initialize()
        {
            if (_initialized)
            {
                return;
            }
            using (await _initializedLock.EnterAsync())
                if (!_initialized)
                {
                    var count = await InitializeFromData();

                    if (count == 0)
                    {
                        count = await InitializeFromBackup();

                        if (count == 0 && _settings.DataDir.IsNullOrWhiteSpace())
                        {
                            throw new Exception($"No data available: {_settings}");
                        }
                    }
                    _initialized.Value = true;
                }
        }