diff --git a/Source/Meadow.Foundation.Libraries_and_Frameworks/Graphics.MicroLayout/Driver/DisplayScreen.cs b/Source/Meadow.Foundation.Libraries_and_Frameworks/Graphics.MicroLayout/Driver/DisplayScreen.cs index fb9948c29a..f0556e70a3 100644 --- a/Source/Meadow.Foundation.Libraries_and_Frameworks/Graphics.MicroLayout/Driver/DisplayScreen.cs +++ b/Source/Meadow.Foundation.Libraries_and_Frameworks/Graphics.MicroLayout/Driver/DisplayScreen.cs @@ -147,6 +147,45 @@ public void EndUpdate() } private void DrawLoop() + { + if(Resolver.App != null) + { + DrawLoopThreaded(); ; + } + else + { + DrawLoopOnCaller(); + } + } + + private void DrawLoopOnCaller() + { + while (true) + { + { + if (!_updateInProgress && (IsInvalid || Controls.Any(c => c.IsInvalid))) + { + _graphics.Clear(BackgroundColor); + + lock (Controls.SyncRoot) + { + foreach (var control in Controls) + { + if (control != null) + // until micrographics supports invalidating regions, we have to invalidate everything when one control needs updating + RefreshTree(control); + } + } + _graphics.Show(); + IsInvalid = false; + } + } + + Thread.Sleep(50); + } + } + + private void DrawLoopThreaded() { while (true) { @@ -160,14 +199,17 @@ private void DrawLoop() { foreach (var control in Controls) { + if(control != null) // until micrographics supports invalidating regions, we have to invalidate everything when one control needs updating - RefreshTree(control); + RefreshTree(control); } } _graphics.Show(); IsInvalid = false; } - }); + } + + ); Thread.Sleep(50); }