public async static Task <bool> LoadBankTaskInSortOrderasync(bool b = false, int i = -1) { try { if (dtBank.Rows.Count > 0) { dtBank.Clear( ); } if (Bankcollection.Items.Count > 0) { Bankcollection.ClearItems( ); } Bankcollection = null; Bankcollection = new BankCollection( ); Console.WriteLine($"Calling Task.Run in Bankcollection ...."); await Task.Run(async( ) => { Console.WriteLine($"Calling LoadBankData in Task.Run in Bankcollection ...."); await LoadBankData( ); Console.WriteLine($"Returned from LoadBankData in Task.Run in Bankcollection ...."); Application.Current.Dispatcher.Invoke( async( ) => { Console.WriteLine($"Calling LoadBankCollection in Task.Run in Bankcollection ...."); await LoadBankCollection( ); Console.WriteLine($"Returned from LoadBankCollection in Task.Run in Bankcollection ...."); }); }); Console.WriteLine($"**** END **** OF ASYNC CALL METHOD {dtBank . Rows . Count} records in DataTable, {Bankcollection . Count} in Bankcollection ...."); Console.WriteLine($"**** END **** SENDING CALLBACK MESSAGE TO SQLDBVIEWER WINDOW TO LOAD THEIR DATAGRID !!!"); if (BankDataLoaded != null) { BankDataLoaded.Invoke(Bankcollection, new LoadedEventArgs { CallerDb = "BANKACCOUNT", DataSource = Bankcollection }); } } catch (Exception ex) { Console.WriteLine($"ERROR in LoadBankTaskInSortOrderAsync() : {ex . Message}, : {ex . Data}"); return(false); } return(true); }
/// <summary> /// Main Method for loading Bank Account data to our global BankCollection.Basnkcollection /// </summary> /// <returns></returns> public static BankCollection LoadBank(int ViewerType, bool NotifyAll = false) { // Called to Load/reload the One & Only Bankcollection data source if (dtBank.Rows.Count > 0) { dtBank.Clear( ); } if (Bankinternalcollection == null) { Bankinternalcollection = new BankCollection( ); Console.WriteLine($"\n ***** SQL WARNING Created a NEW MasterBankCollection ..................."); } // Load data fro SQL into dtBank Datatable LoadBankData( ); if (Bankinternalcollection == null) { Bankinternalcollection = new BankCollection( ); Console.WriteLine($"\n ***** SQL WARNING Created a NEW Bankinternalcollection ..................."); } if (Bankinternalcollection.Count > 0) { Bankinternalcollection.ClearItems( ); } // this returns "Bankinternalcollection" as a pointer to the correct viewer LoadBankCollection( ); // We now have the pointer to the the Bank data in variable Bankinternalcollection if (Flags.IsMultiMode == false) { // Finally fill and return The global Dataset SelectViewer(ViewerType, Bankinternalcollection); return(Bankinternalcollection); } else { // return the "working copy" pointer, it has filled the relevant collection to match the viewer return(Bankinternalcollection); } }
/// <summary> /// Method used ONLY when working with Multi accounts data /// </summary> /// <param name="b"></param> /// <param name="mode"></param> /// <returns></returns> public async Task <BankCollection> ReLoadBankData(bool b = false, int mode = -1) { if (dtBank.Rows.Count > 0) { dtBank.Clear( ); } //await LoadBankTaskInSortOrderasync ( false ); BankCollection temp = new BankCollection(); if (temp.Count > 0) { temp.ClearItems( ); } LoadBankData( ); if (Flags.IsMultiMode) { // Loading subset of multi accounts only // BankCollection bank = new BankCollection(); temp = LoadBankTest(temp); // Just return the subset of data without updating our // //Flags pointer or class Bankcollection pointer return(temp); } else { // :Loading full total or data Bankinternalcollection = LoadBank(mode); SelectViewer(mode, Bankinternalcollection); // Set our globals etc // Bankcollection = Bankinternalcollection; // Flags . BankCollection = Bankcollection = Bankinternalcollection; return(Bankinternalcollection); } }