-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 (Service): breakpoint service doesn't work when interactive per pag…
…e/component enabled (#2131)
- Loading branch information
Showing
4 changed files
with
55 additions
and
30 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
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,24 @@ | ||
namespace Masa.Blazor.Utils; | ||
|
||
public class Throttle(TimeSpan delay) | ||
{ | ||
private DateTime _lastExecutionTime = DateTime.MinValue; | ||
private readonly object _lock = new(); | ||
|
||
public Throttle(int delay) : this(TimeSpan.FromMilliseconds(delay)) | ||
{ | ||
} | ||
|
||
public void Execute(Action action) | ||
{ | ||
lock (_lock) | ||
{ | ||
var now = DateTime.UtcNow; | ||
if (now - _lastExecutionTime >= delay) | ||
{ | ||
_lastExecutionTime = now; | ||
action(); | ||
} | ||
} | ||
} | ||
} |