Add NotifyAfterDelay helper method

This commit is contained in:
RaidMax 2023-04-05 22:26:42 -05:00
parent ffb32ccc45
commit af2925287d

View File

@ -1331,5 +1331,24 @@ namespace SharedLibraryCore
return serviceCollection;
}
public static void NotifyAfterDelay(TimeSpan duration, Func<Task> action) =>
NotifyAfterDelay((int)duration.TotalMilliseconds, action);
public static void NotifyAfterDelay(int delayMs, Func<Task> action)
{
Task.Run(async () =>
{
try
{
await Task.Delay(delayMs);
await action();
}
catch
{
// ignored
}
});
}
}
}