Skip to content

Commit

Permalink
Use seperate lock object
Browse files Browse the repository at this point in the history
  • Loading branch information
Rem0o committed Jan 30, 2024
1 parent c4ad8ad commit ebf671d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions OpenFanPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace FanControl.OpenFanPlugin
public class OpenFanPlugin : IPlugin2
{
private bool _OpenFanInitialized;
private object _serialLock = new object();
private OpenFan_Serial _serial;
private OpenFanManagementControlSensor[] _fanControls;
private OpenFanManagementFanSensor[] _fanSensors;
Expand All @@ -28,7 +29,7 @@ public void Close()
if (_OpenFanInitialized)
{
_OpenFanInitialized = false;
lock (_serial)
lock (_serialLock)
{
_serial.Dispose();
}
Expand All @@ -43,7 +44,7 @@ public void Initialize()
_OpenFanInitialized = true;
_logger.Log("OpenFAN plugin loaded.");

lock(_serial)
lock(_serialLock)
{
_serial = new OpenFan_Serial();
}
Expand All @@ -66,7 +67,7 @@ public void Load(IPluginSensorsContainer container)

public void Update()
{
lock (_serial)
lock (_serialLock)
{
try
{
Expand Down

0 comments on commit ebf671d

Please # to comment.