Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

DelayedExecuter

View DelayedExecuter.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
 
namespace NilzorLib.Metro.Core
{
public class DelayedExecuter
{
DispatcherTimer _timer;
 
public static void ExecuteAfter(int ms, Action action)
{
ExecuteAfter(new TimeSpan(0,0,0,0,ms), action);
}
 
public static void ExecuteAfter(TimeSpan span, Action action)
{
var p = new DelayedExecuter();
p._timer = new DispatcherTimer();
p._timer.Interval = span;
p._timer.Tick += (a,b) =>
{
p._timer.Stop();
p._timer = null;
action();
};
p._timer.Start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.