public static UVTimer Every(Loop loop, TimeSpan repeat, Action callback) { var timer = new UVTimer(loop); timer.Tick += callback; timer.Start(repeat, repeat); return timer; }
public static UVTimer Every(Loop loop, TimeSpan repeat, Action callback) { var timer = new UVTimer(loop); timer.Tick += callback; timer.Start(repeat, repeat); return(timer); }
public static void Main(string[] args) { Loop.Default.Run(async () => { var t = new UVTimer(); var now = DateTime.Now; await t.StartAsync(TimeSpan.FromSeconds(1)); Console.WriteLine(DateTime.Now - now); }); }
public static void Main(string[] args) { Loop.Default.Run(async () => { var t = new UVTimer(); var stopwatch = Stopwatch.StartNew(); await t.StartAsync(TimeSpan.FromSeconds(1)); stopwatch.Stop(); Console.WriteLine(stopwatch.Elapsed); }); }
public StatusBarTemplate(QuasselClient client) { Client = client; Client.BufferSyncer.Synced += (obj) => { Invalid = true; }; var timer = new UVTimer(); timer.Tick += () => Invalid = true; timer.Start(TimeSpan.Zero, TimeSpan.FromSeconds(1)); }
public static UVTimer Once(Loop loop, TimeSpan timeout, Action callback) { var timer = new UVTimer(loop); timer.Tick += () => { if (callback != null) { callback(); } timer.Close(); }; timer.Start(timeout, TimeSpan.Zero); return(timer); }
public Fanbar(string root, int id) { Root = root; ID = id; Value = -1; timer = new UVTimer(Application.Loop); Get(PWM, (val) => { Invalid = true; Value = val; }); timer.Start(TimeSpan.FromSeconds(1), () => { Get(FanInput, (val) => RPM = val); }); }
public static UVTimer Times(Loop loop, int times, TimeSpan repeat, Action <int> callback) { var timer = new UVTimer(loop); int i = 0; timer.Tick += () => { i++; if (callback != null) { callback(i); } if (i >= times) { timer.Close(); } }; timer.Start(repeat, repeat); return(timer); }
private static Action <Exception> End(TimeSpan timeSpan, Action <Exception> callback) { UVTimer timer = null; Action <Exception> end = (Exception exception) => { if (timer != null) { timer.Close(); timer = null; if (callback != null) { callback(exception); } } }; timer = UVTimer.Once(timeSpan, () => end(new TimeoutException())); return(end); }
public static UVTimer Once(Loop loop, TimeSpan timeout, Action callback) { var timer = new UVTimer(loop); timer.Tick += () => { if (callback != null) { callback(); } timer.Close(); }; timer.Start(timeout, TimeSpan.Zero); return timer; }
public static UVTimer Times(Loop loop, int times, TimeSpan repeat, Action<int> callback) { var timer = new UVTimer(loop); int i = 0; timer.Tick += () => { i++; if (callback != null) { callback(i); } if (i >= times) { timer.Close(); } }; timer.Start(repeat, repeat); return timer; }