mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2025-12-06 07:12:01 +01:00
18 lines
495 B
C#
18 lines
495 B
C#
|
|
namespace CommonHelpers
|
||
|
|
{
|
||
|
|
public static class Dispatcher
|
||
|
|
{
|
||
|
|
public static CancellationTokenSource RunWithDelay(int delayMs, Action action)
|
||
|
|
{
|
||
|
|
var cancellationTokenSource = new CancellationTokenSource();
|
||
|
|
|
||
|
|
Task.Delay(1000, cancellationTokenSource.Token).ContinueWith(_ =>
|
||
|
|
{
|
||
|
|
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(action);
|
||
|
|
});
|
||
|
|
|
||
|
|
return cancellationTokenSource;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|