You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.UI/Extensions/Extensions.cs

27 lines
848 B

using System;
using System.Windows.Threading;
namespace MediaBrowser.UI.Extensions
{
public static class Extensions
{
/// <summary>
/// Invokes an action after a specified delay
/// </summary>
/// <param name="dispatcher">The dispatcher.</param>
/// <param name="action">The action.</param>
/// <param name="delayMs">The delay ms.</param>
public static void InvokeWithDelay(this Dispatcher dispatcher, Action action, long delayMs)
{
var timer = new DispatcherTimer(DispatcherPriority.Normal, dispatcher);
timer.Interval = TimeSpan.FromMilliseconds(delayMs);
timer.Tick += (sender, args) =>
{
timer.Stop();
action();
};
timer.Start();
}
}
}