mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
fix: add mutex to prevent multiple scenarios from running at once
This commit is contained in:
@@ -5,6 +5,7 @@ using Serilog.Events;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -48,6 +49,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
||||||
|
|
||||||
|
private Mutex _scenarioChange = new Mutex();
|
||||||
|
|
||||||
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
@@ -205,6 +208,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_scenarioChange.WaitOne();
|
||||||
|
|
||||||
if (value != _currentScenario)
|
if (value != _currentScenario)
|
||||||
{
|
{
|
||||||
// Deactivate the old scenario first
|
// Deactivate the old scenario first
|
||||||
@@ -230,6 +237,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_scenarioChange.ReleaseMutex();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user