-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Surpress themal mode events when switching power modes manually. (#621)
- Loading branch information
1 parent
63d52a7
commit d8cfaf4
Showing
3 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
|
||
namespace LenovoLegionToolkit.Lib.Utils; | ||
|
||
public class ThreadSafeCounter | ||
{ | ||
private readonly object _lock = new(); | ||
|
||
private int _counter; | ||
|
||
public bool Decrement() | ||
{ | ||
lock (_lock) | ||
{ | ||
var value = _counter < 1; | ||
_counter = Math.Max(0, _counter - 1); | ||
return value; | ||
} | ||
} | ||
|
||
public void Increment() | ||
{ | ||
lock (_lock) | ||
{ | ||
_counter++; | ||
} | ||
} | ||
} |