Add NotifyAfterDelay helper method
This commit is contained in:
parent
ffb32ccc45
commit
af2925287d
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user