Remove extra library load and move comments to Main

This commit is contained in:
Mbucari 2023-07-09 10:05:51 -06:00
parent 932472cb91
commit 296c2b43eb
2 changed files with 10 additions and 6 deletions

View File

@ -15,10 +15,6 @@ namespace LibationWinForms
{ {
InitializeComponent(); 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.RestoreSizeAndLocation(Configuration.Instance);
this.FormClosing += (_, _) => this.SaveSizeAndLocation(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' // 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; Shown += Form1_Shown;
} }

View File

@ -50,7 +50,15 @@ namespace LibationWinForms
// migrations which require Forms or are long-running // migrations which require Forms or are long-running
RunWindowsOnlyMigrations(config); 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)); libraryLoadTask = Task.Run(() => DbContexts.GetLibrary_Flat_NoTracking(includeParents: true));
MessageBoxLib.VerboseLoggingWarning_ShowIfTrue(); MessageBoxLib.VerboseLoggingWarning_ShowIfTrue();