Skip to content

Commit 52913ed

Browse files
committed
Fixed an issue where the update settings could be called multiple times.
1 parent 777282b commit 52913ed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Exceptionless/ExceptionlessClient.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public ExceptionlessClient(ExceptionlessConfiguration configuration) {
4949

5050
_submissionClient = new Lazy<ISubmissionClient>(() => Configuration.Resolver.GetSubmissionClient());
5151
_lastReferenceIdManager = new Lazy<ILastReferenceIdManager>(() => Configuration.Resolver.GetLastReferenceIdManager());
52-
_updateSettingsTimer = new Timer(state => SettingsManager.UpdateSettings(Configuration), null, GetInitialSettingsDelay(), Configuration.UpdateSettingsWhenIdleInterval ?? TimeSpan.FromMilliseconds(-1));
52+
_updateSettingsTimer = new Timer(OnUpdateSettings, null, GetInitialSettingsDelay(), Configuration.UpdateSettingsWhenIdleInterval ?? TimeSpan.FromMilliseconds(-1));
5353
}
5454

5555
private TimeSpan GetInitialSettingsDelay() {
@@ -66,6 +66,16 @@ private void OnConfigurationChanged(object sender, EventArgs e) {
6666
_updateSettingsTimer.Change(!_queue.IsValueCreated ? GetInitialSettingsDelay() : interval, interval);
6767
}
6868

69+
private bool _isUpdatingSettings;
70+
private void OnUpdateSettings(object state) {
71+
if (_isUpdatingSettings || !Configuration.IsValid)
72+
return;
73+
74+
_isUpdatingSettings = true;
75+
SettingsManager.UpdateSettings(Configuration);
76+
_isUpdatingSettings = false;
77+
}
78+
6979
public ExceptionlessConfiguration Configuration { get; private set; }
7080

7181
/// <summary>

0 commit comments

Comments
 (0)