mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:36:31 +00:00
rework to Azaion.Suite
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace Azaion.Annotator.Extensions;
|
||||
|
||||
public static class ThrottleExt
|
||||
{
|
||||
private static bool _throttleOn;
|
||||
public static async Task Throttle(Func<Task> func, TimeSpan? throttleTime = null)
|
||||
{
|
||||
if (_throttleOn)
|
||||
return;
|
||||
|
||||
_throttleOn = true;
|
||||
await func();
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500));
|
||||
_throttleOn = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user