//-------------------------------------------------------------------------------------------------------------------------------------------------// protected virtual void OnCustDataLoaded( ) { if (CustDataLoaded != null) { Console.WriteLine($"Broadcasting from OnCustDataLoaded in "); CustDataLoaded?.Invoke(this, new LoadedEventArgs( ) { DataSource = Custcollection, CallerDb = "CUSTOMER" }); } }
public static void TriggerCustDataLoaded(object obj, LoadedEventArgs e) { CustDataLoaded?.Invoke(obj, e); }
//**************************************************************************************************************************************************************// // Entry point for all data load/Reload //**************************************************************************************************************************************************************// public static async Task <bool> LoadCustomerTaskInSortOrderAsync(bool isOriginator, int mode = -1) { try { if (dtCust.Rows.Count > 0) { dtCust.Clear( ); } if (Custcollection.Items.Count > 0) { Custcollection.ClearItems( ); } Custcollection = new CustCollection( ); Console.WriteLine($"Calling Task.Run in custcollection ...."); await Task.Run(async( ) => { Console.WriteLine($"Calling LoadCustDataSql in Task.Run in Bankcollection ...."); try { await LoadCustDataSql( ); Console.WriteLine($"Returned from LoadCustDataSql in Task.Run in Custcollection ...."); } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustData Task{ex.Message}, {ex.Data}...."); } Application.Current.Dispatcher.Invoke( async( ) => { Console.WriteLine($"Calling LoadCustomerCollection in Task.Run in Custcollection ...."); try { await LoadCustomerCollection( ); Console.WriteLine($"Returned from LoadCustmerCollection Task.Run in Custcollection ...."); } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustomerCollection Task {ex . Message}, {ex . Data}...."); } }); }); Console.WriteLine($"**** END **** OF ASYNC CALL METHOD {dtCust . Rows . Count} records in DataTable, {Custcollection . Count} in Custcollection ...."); Console.WriteLine($"**** END **** SENDING CALLBACK MESSAGE TO SQLDBVIEWER WINDOW TO LOAD THEIR DATAGRID !!!"); if (CustDataLoaded != null) { CustDataLoaded.Invoke(Custcollection, new LoadedEventArgs { CallerDb = "CUSTOMER", DataSource = Custcollection }); } } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustomerTaskInSortOrderAsync() : {ex . Message}, : {ex . Data}"); return(false); } return(true); }