From ff33dfb95abea8159d3f9de47bd5115c075adc83 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Wed, 30 Dec 2020 22:48:42 +1300 Subject: [PATCH] Fixed SteamGame race condition Found issue where the IsRunning process checks were breaking because they were being running before the steam process had a chance to create the process. This meant the information wasn't aviailable for the SteamGame.IsRunning function to inspect. Fixed by adding in a 0.5 sec delay. --- DisplayMagician/ShortcutRepository.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index d8a4ef8..053ffcd 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -743,12 +743,18 @@ namespace DisplayMagician Console.WriteLine($"Starting Steam Game: {steamGameToRun.Name}"); var steamProcess = Process.Start(address); + // Delay 500ms + Thread.Sleep(500); + // Wait for Steam game to update if needed for (int secs = 0; secs >= (shortcutToUse.StartTimeout * 1000); secs += 500) { if (!steamGameToRun.IsUpdating) { + // Delay 500ms + Thread.Sleep(500); + if (steamGameToRun.IsRunning) { logger.Info($"Found the '{steamGameToRun.Name}' process has started");