This commit is contained in:
snltty
2024-10-20 18:50:45 +08:00
parent 045dd9762e
commit 1aa5664e5d
29 changed files with 315 additions and 273 deletions

View File

@@ -27,7 +27,21 @@ namespace linker.libs
}
});
}
public static void SetInterval(Func<Task<bool>> action, int delayMs)
public static void SetInterval(Func<bool> action, Func<int> delay)
{
Task.Run(async () =>
{
while (true)
{
if (action() == false)
{
break;
}
await Task.Delay(delay()).ConfigureAwait(false);
}
});
}
public static void SetInterval(Func<Task<bool>> action, Func<int> delay)
{
Task.Run(async () =>
{
@@ -37,7 +51,7 @@ namespace linker.libs
{
break;
}
await Task.Delay(delayMs).ConfigureAwait(false);
await Task.Delay(delay()).ConfigureAwait(false);
}
});
}