public class ActionDispatcherTimer : System.Windows.Threading.DispatcherTimerTaken from: http://blog.bodurov.com/How-to-Create-setTimeout-Function-in-Silverlight/
{
public Action Action { get; set; }
}
public static class UIHelper
{
public static void DelayStart(int milliseconds, Action action)
{
var timer = new ActionDispatcherTimer
{
Interval = new TimeSpan(0, 0, 0, 0, milliseconds),
Action = action
};
timer.Tick += onTick;
timer.Start();
}
private static void onTick(object sender, EventArgs arg)
{
var t = sender as ActionDispatcherTimer;
t.Stop();
t.Action();
t.Tick -= onTick;
}
}
//usage: after 5 seconds execute ths lambda
UIHelper.DelayStart(5000, () => status = "Completed");
Wednesday, 21 November 2012
Delay in Silverlight
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment