aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI/Extensions/Extensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.UI/Extensions/Extensions.cs')
-rw-r--r--MediaBrowser.UI/Extensions/Extensions.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/MediaBrowser.UI/Extensions/Extensions.cs b/MediaBrowser.UI/Extensions/Extensions.cs
new file mode 100644
index 000000000..1d0d7d1c2
--- /dev/null
+++ b/MediaBrowser.UI/Extensions/Extensions.cs
@@ -0,0 +1,26 @@
+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();
+ }
+ }
+}