Skip to content

Commit

Permalink
fix razer battery fetcher not releasing mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Jul 10, 2024
1 parent c129072 commit 0d0c84e
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ private void UpdateBattery()
{
const int vendorId = 0x1532;

Mutex mutex = new(false, "Global\\RazerLinkReadWriteGuardMutex");
using Mutex mutex = new(false, "Global\\RazerLinkReadWriteGuardMutex");

try
{
if (!mutex.WaitOne(TimeSpan.FromMilliseconds(2000), false))
if (!mutex.WaitOne(TimeSpan.FromMilliseconds(2000), true))
{
mutex.Dispose();
return;
}
}
Expand All @@ -65,7 +64,7 @@ private void UpdateBattery()
}

var res = GetValue(vendorId);
mutex.Dispose();
mutex.ReleaseMutex();

if (res == null)
{
Expand Down

0 comments on commit 0d0c84e

Please sign in to comment.