Skip to content

Commit

Permalink
Add NotifyAfterDelay helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
RaidMax committed Apr 6, 2023
1 parent 6faa9b0 commit 287ac9c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions SharedLibraryCore/Utilities.cs
Expand Up @@ -1331,5 +1331,24 @@ public static string FindRuleForReason(this string reason, ApplicationConfigurat

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
}
});
}
}
}

0 comments on commit 287ac9c

Please sign in to comment.