From e1d23df630cf4ef410cdc37a725a19e45b905731 Mon Sep 17 00:00:00 2001 From: Leonardo Ascione Date: Fri, 14 Aug 2020 16:57:37 +0200 Subject: [PATCH] Fix high CPU usage in simulators Actually just using some sleep commands while simulator is not null. --- Snacks/Simulator/SnackSimThread.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Snacks/Simulator/SnackSimThread.cs b/Snacks/Simulator/SnackSimThread.cs index c8be0de..a550f7d 100644 --- a/Snacks/Simulator/SnackSimThread.cs +++ b/Snacks/Simulator/SnackSimThread.cs @@ -128,6 +128,7 @@ private void ThreadRoutine() if (!canRun) { mutex.ReleaseMutex(); + Thread.Sleep(100); return; } @@ -177,6 +178,10 @@ private void ThreadRoutine() mutex.ReleaseMutex(); } } + else + { + Thread.Sleep(100); + } } }