protected DbConfigurationProvider(DbConfigurationSource source, ConfigurationStorageBase storage) { Storage = storage; storage.InitializeAsync().GetAwaiter().GetResult(); Event += AddOrUpdateKeyValue; Event += RemoveKeyValue; _timer = new Timer(_timerCallback, this, source.ReloadDelay, source.ReloadDelay); _timer1 = new Timer(_timerCallback1, this, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); }
protected DbConfigurationProvider(DbConfigurationSource source, ConfigurationStorageBase storage) { Source = source; Storage = storage; storage.InitializeAsync().GetAwaiter().GetResult(); storage.Event += ReLoad; _timer = new Timer(_timerCallback, this, source.ReloadDelay, source.ReloadDelay); }
protected DbConfigurationProvider(DbConfigurationSource source, ConfigurationStorageBase storage) { Source = source; Storage = storage; storage.InitializeAsync().GetAwaiter().GetResult(); _timer = new Timer(_timerCallback, this, TimeSpan.FromSeconds(Source.ReloadDelay), TimeSpan.FromSeconds(Source.ReloadDelay)); Task.Run(() => { while (true) { var events = new List <Event>(); while (!storage.Events.IsEmpty) { if (storage.Events.TryDequeue(out var @event)) { events.Add(@event); } } ReLoad(events); Thread.Sleep(500); } }); }