From b87fd489a121b154304653dbf533623089020da7 Mon Sep 17 00:00:00 2001 From: tznind Date: Thu, 13 Oct 2022 09:52:12 +0100 Subject: [PATCH] Fix locking for the entire RunIdle callback execution --- Terminal.Gui/Core/MainLoop.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Core/MainLoop.cs b/Terminal.Gui/Core/MainLoop.cs index 43789e228..e71367646 100644 --- a/Terminal.Gui/Core/MainLoop.cs +++ b/Terminal.Gui/Core/MainLoop.cs @@ -306,9 +306,12 @@ namespace Terminal.Gui { Driver.MainIteration (); + bool runIdle = false; lock (idleHandlersLock) { - if (idleHandlers.Count > 0) - RunIdle (); + runIdle = idleHandlers.Count > 0; + } + if (runIdle) { + RunIdle (); } }