From 18ca92eccd8476632751779626747602c01268b8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 13 Feb 2015 14:26:10 +0100 Subject: [PATCH] Share animation timer. Previously every new subscription was creating a new timer. Using Publish().RefCount() makes all subscriptions share the same one. --- Perspex.Animation/Animate.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Perspex.Animation/Animate.cs b/Perspex.Animation/Animate.cs index 266585a13f..1deb8e3061 100644 --- a/Perspex.Animation/Animate.cs +++ b/Perspex.Animation/Animate.cs @@ -34,7 +34,10 @@ namespace Perspex.Animation { Stopwatch = new Stopwatch(); Stopwatch.Start(); - Timer = Observable.Interval(Tick, PerspexScheduler.Instance).Select(_ => Stopwatch.Elapsed); + Timer = Observable.Interval(Tick, PerspexScheduler.Instance) + .Select(_ => Stopwatch.Elapsed) + .Publish() + .RefCount(); } ///