mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 17:36:30 +00:00
add offset
fixes add visual validation border and validate functionality
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
namespace Azaion.Common.Extensions;
|
||||
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static bool In<T>(this T obj, params T[] objects) =>
|
||||
objects.Contains(obj);
|
||||
}
|
||||
@@ -2,18 +2,34 @@
|
||||
|
||||
public static class ThrottleExt
|
||||
{
|
||||
private static bool _throttleOn;
|
||||
public static async Task Throttle(this Func<Task> func, TimeSpan? throttleTime = null, CancellationToken cancellationToken = default)
|
||||
private static bool _throttleRunFirstOn;
|
||||
public static async Task ThrottleRunFirst(this Func<Task> func, TimeSpan? throttleTime = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_throttleOn)
|
||||
if (_throttleRunFirstOn)
|
||||
return;
|
||||
|
||||
_throttleOn = true;
|
||||
_throttleRunFirstOn = true;
|
||||
await func();
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500), cancellationToken);
|
||||
_throttleOn = false;
|
||||
_throttleRunFirstOn = false;
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private static bool _throttleRunAfter;
|
||||
public static async Task ThrottleRunAfter(this Func<Task> func, TimeSpan? throttleTime = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_throttleRunAfter)
|
||||
return;
|
||||
|
||||
_throttleRunAfter = true;
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(throttleTime ?? TimeSpan.FromMilliseconds(500), cancellationToken);
|
||||
await func();
|
||||
_throttleRunAfter = false;
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user