From 60550caf9917367ddb473e3b9e4df4b7ff3aaf2c Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 11 Apr 2025 13:26:01 -0500 Subject: [PATCH] fix: add lock for threadsafety Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Monitoring/GenericCommunicationMonitor.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs index 5bc505e2..d012ff2c 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs @@ -201,12 +201,15 @@ namespace PepperDash.Essentials.Core private void BeginPolling() { - if(PollTimer != null) + lock (_pollTimerLock) { - return; - } + if (PollTimer != null) + { + return; + } - PollTimer = new Timer(o => Poll(), null, 0, PollTime); + PollTimer = new Timer(o => Poll(), null, 0, PollTime); + } } ///