public async Task RunAnimation() { Assert.Ignore("This test is *far* too strict to reliably pass on different machines. A 20ms window is not enough"); int n = 0; DateTime t = DateTime.MinValue; int t1 = 0, t2 = 0; DispatchService.RunAnimation(() => { n++; if (n == 1) { t = DateTime.Now; return(100); } else if (n == 2) { t1 = (int)(DateTime.Now - t).TotalMilliseconds; t = DateTime.Now; return(200); } else { t2 = (int)(DateTime.Now - t).TotalMilliseconds; return(-1); } }); await Task.Delay(1000); Assert.IsTrue(t1 >= 100 && t1 <= 120); Assert.IsTrue(t2 >= 200 && t1 <= 220); }
public async Task RunAnimation() { int n = 0; DateTime t = DateTime.MinValue; int t1 = 0, t2 = 0; DispatchService.RunAnimation(() => { n++; if (n == 1) { t = DateTime.Now; return(100); } else if (n == 2) { t1 = (int)(DateTime.Now - t).TotalMilliseconds; t = DateTime.Now; return(200); } else { t2 = (int)(DateTime.Now - t).TotalMilliseconds; return(-1); } }); await Task.Delay(1000); Assert.IsTrue(t1 >= 100 && t1 <= 120); Assert.IsTrue(t2 >= 200 && t1 <= 220); }
public IDisposable StartAnimation(Action <Gdk.Pixbuf> renderer) { int currentFrame = 0; return(DispatchService.RunAnimation(delegate { renderer(images [currentFrame]); var res = pauses [currentFrame]; currentFrame = (currentFrame + 1) % images.Count; return res; })); }