Found longstanding dual game load issue

Should stop the double loading of games once and for all.
This commit is contained in:
Terry MacDonald 2021-10-31 20:47:46 +13:00
parent 2da00a55ec
commit 275adbeda6
2 changed files with 15 additions and 14 deletions

View File

@ -44,6 +44,7 @@ namespace DisplayMagician {
public static LoadingForm AppSplashScreen; public static LoadingForm AppSplashScreen;
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static SharedLogger sharedLogger; private static SharedLogger sharedLogger;
private static bool _gamesLoaded = false;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
@ -318,7 +319,6 @@ namespace DisplayMagician {
{ {
// Try to load all the games in parallel to this process // Try to load all the games in parallel to this process
//Task.Run(() => LoadGamesInBackground()); //Task.Run(() => LoadGamesInBackground());
LoadGamesInBackground();
// Set the --trace or --debug options if supplied // Set the --trace or --debug options if supplied
if (trace.HasValue()) if (trace.HasValue())
@ -378,7 +378,9 @@ namespace DisplayMagician {
{ {
logger.Debug($"RunShortcut commandline command was invoked!"); logger.Debug($"RunShortcut commandline command was invoked!");
// // Load the games in background onexecute
LoadGamesInBackground();
RunShortcut(argumentShortcut.Value); RunShortcut(argumentShortcut.Value);
return 0; return 0;
}); });
@ -705,8 +707,7 @@ namespace DisplayMagician {
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Program/StartUpNormally exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Error(ex, $"Program/StartUpApplication exception while trying to create directory {AppIconPath}");
logger.Error(ex, $"Program/StartUpNormally exception while trying to create directory {AppIconPath}");
} }
} }
@ -723,8 +724,7 @@ namespace DisplayMagician {
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Program/StartUpNormally exception 2: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Error(ex, $"Program/StartUpApplication exception create Icon files for future use in {AppIconPath}");
logger.Error(ex, $"Program/StartUpNormally exception create Icon files for future use in {AppIconPath}");
} }
IPCService.GetInstance().Status = InstanceStatus.User; IPCService.GetInstance().Status = InstanceStatus.User;
@ -743,8 +743,7 @@ namespace DisplayMagician {
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Program/StartUpNormally exception 3: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); logger.Error(ex, $"Program/StartUpApplication top level exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
logger.Error(ex, $"Program/StartUpNormally top level exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
MessageBox.Show( MessageBox.Show(
ex.Message, ex.Message,
Language.Fatal_Error, Language.Fatal_Error,
@ -839,7 +838,9 @@ namespace DisplayMagician {
public static bool LoadGamesInBackground() public static bool LoadGamesInBackground()
{ {
logger.Debug($"Program/LoadGamesInBackground: Starting"); logger.Trace($"Program/LoadGamesInBackground: Attempting to load games from detected game libraries.");
// Now lets prepare loading all the Steam games we have installed // Now lets prepare loading all the Steam games we have installed
Action loadSteamGamesAction = new Action(() => Action loadSteamGamesAction = new Action(() =>
{ {
@ -1042,9 +1043,9 @@ namespace DisplayMagician {
game.GameBitmap = bm; game.GameBitmap = bm;
} }
_gamesLoaded = true;
return true; return true;
} }
public static string HotkeyToString(Keys hotkey) public static string HotkeyToString(Keys hotkey)

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information // Version information
[assembly: AssemblyVersion("2.1.0.73")] [assembly: AssemblyVersion("2.1.0.78")]
[assembly: AssemblyFileVersion("2.1.0.73")] [assembly: AssemblyFileVersion("2.1.0.78")]
[assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]