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.
This commit is contained in:
Terry MacDonald 2020-12-30 22:48:42 +13:00
parent 73d1735769
commit ff33dfb95a

View File

@ -743,12 +743,18 @@ namespace DisplayMagician
Console.WriteLine($"Starting Steam Game: {steamGameToRun.Name}"); Console.WriteLine($"Starting Steam Game: {steamGameToRun.Name}");
var steamProcess = Process.Start(address); var steamProcess = Process.Start(address);
// Delay 500ms
Thread.Sleep(500);
// Wait for Steam game to update if needed // Wait for Steam game to update if needed
for (int secs = 0; secs >= (shortcutToUse.StartTimeout * 1000); secs += 500) for (int secs = 0; secs >= (shortcutToUse.StartTimeout * 1000); secs += 500)
{ {
if (!steamGameToRun.IsUpdating) if (!steamGameToRun.IsUpdating)
{ {
// Delay 500ms
Thread.Sleep(500);
if (steamGameToRun.IsRunning) if (steamGameToRun.IsRunning)
{ {
logger.Info($"Found the '{steamGameToRun.Name}' process has started"); logger.Info($"Found the '{steamGameToRun.Name}' process has started");