From 296c2b43eb727affa8c889ab95b1f72455eba5f5 Mon Sep 17 00:00:00 2001 From: Mbucari <37587114+Mbucari@users.noreply.github.com> Date: Sun, 9 Jul 2023 10:05:51 -0600 Subject: [PATCH] Remove extra library load and move comments to Main --- Source/LibationWinForms/Form1.cs | 6 +----- Source/LibationWinForms/Program.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/LibationWinForms/Form1.cs b/Source/LibationWinForms/Form1.cs index 79754f6d..45eecf66 100644 --- a/Source/LibationWinForms/Form1.cs +++ b/Source/LibationWinForms/Form1.cs @@ -15,10 +15,6 @@ namespace LibationWinForms { InitializeComponent(); - // Pre-requisite: - // Before calling anything else, including subscribing to events, ensure database exists. If we wait and let it happen lazily, race conditions and errors are likely during new installs - using var _ = DbContexts.GetContext(); - this.RestoreSizeAndLocation(Configuration.Instance); this.FormClosing += (_, _) => this.SaveSizeAndLocation(Configuration.Instance); @@ -55,7 +51,7 @@ namespace LibationWinForms // Configure_Grid(); // since it's just this, can keep here. If it needs more, then give grid it's own 'partial class Form1' { - LibraryCommands.LibrarySizeChanged += (_, __) => Invoke(productsDisplay.DisplayAsync); + LibraryCommands.LibrarySizeChanged += (_, __) => Invoke(() => productsDisplay.DisplayAsync()); } Shown += Form1_Shown; } diff --git a/Source/LibationWinForms/Program.cs b/Source/LibationWinForms/Program.cs index 36161424..57c1437b 100644 --- a/Source/LibationWinForms/Program.cs +++ b/Source/LibationWinForms/Program.cs @@ -50,7 +50,15 @@ namespace LibationWinForms // migrations which require Forms or are long-running RunWindowsOnlyMigrations(config); - //start loading the db as soon as possible + //*******************************************************************// + // // + // Start loading the library as soon as possible // + // // + // Before calling anything else, including subscribing to events, // + // to ensure database exists. If we wait and let it happen lazily, // + // race conditions and errors are likely during new installs // + // // + //*******************************************************************// libraryLoadTask = Task.Run(() => DbContexts.GetLibrary_Flat_NoTracking(includeParents: true)); MessageBoxLib.VerboseLoggingWarning_ShowIfTrue();