mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:16:30 +00:00
queue + local sqlite WIP
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace Azaion.Common.Extensions;
|
||||
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static bool In<T>(this T obj, params T[] objects) =>
|
||||
objects.Contains(obj);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace Azaion.Annotator.Extensions;
|
||||
namespace Azaion.Common.Extensions;
|
||||
|
||||
public static class ThrottleExt
|
||||
{
|
||||
private static bool _throttleOn;
|
||||
public static async Task Throttle(Func<Task> func, TimeSpan? throttleTime = null)
|
||||
public static async Task Throttle(this Func<Task> func, TimeSpan? throttleTime = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_throttleOn)
|
||||
return;
|
||||
@@ -12,8 +12,8 @@ public static class ThrottleExt
|
||||
await func();
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500));
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500), cancellationToken);
|
||||
_throttleOn = false;
|
||||
});
|
||||
}, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user