public async void ShoppingCartGuard(ShoppingCart.NewEntryEventArgs e) { try { Logger.GetInstance().Log("SCG: triggered"); // DEBUG // Get Scanned entries Entries.Clear(); Logger.GetInstance().Log("SCG: List cleared"); // DEBUG foreach (var entry in _shoppingCart.GetEntries()) { Entries.Add(entry); } Logger.GetInstance().Log($"SCG: Entries added. {Entries.Count} items in list"); // Call a delegate in this thread to set the values of the controls accordingly await LabelArticleCountVar.Dispatcher.BeginInvoke(new SetFields(SetControls), e); } catch (Exception ex) { Logger.GetInstance().Log("--Exception caught in App: " + ex.Message); } }
private void SetControls(ShoppingCart.NewEntryEventArgs e) { try { // Update labels Logger.GetInstance().Log("SCG: Set Controls started"); // DEBUG LabelArticleCountVar.Content = _shoppingCart.GetCountAllArticles(); LabelPriceVar.Content = _shoppingCart.GetPrice() + "€"; Logger.GetInstance().Log($"App: {Entries.Count} entries in List scanned."); // Update grid DataGridEntries.Items.Refresh(); Logger.GetInstance().Log($"App: {Entries.Count} entries in data grid."); } catch (Exception ex) { Logger.GetInstance().Log("--Exception caugth in SetControls: " + ex.Message); } }