mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
Add RunTimer Utility Method
This commit is contained in:
parent
9fb45dc502
commit
ca052f1d31
@ -437,6 +437,19 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="task"></param>
|
/// <param name="task"></param>
|
||||||
public static TaskAwaiter StartAndAwaitTask(Func<Task> task) => new(Service.TaskManager.StartAndAwaitTask(task));
|
public static TaskAwaiter StartAndAwaitTask(Func<Task> task) => new(Service.TaskManager.StartAndAwaitTask(task));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开启一个计时器任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="milliseconds"></param>
|
||||||
|
public static void RunTimer(Action action, int milliseconds)
|
||||||
|
{
|
||||||
|
Service.TaskManager.StartAndAwaitTask(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(milliseconds);
|
||||||
|
}).OnCompleted(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user