private void CalculeStatisticsAgentDoWork(object sender, DoWorkEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { LblCreatedCustomersNumber.Content = _myCustomersManager.HowMuchCustomerCreated(); LblPendingBillsNumber.Content = _myBillsManager.HowMuchBillsCreated(true); LblSentBillsNumber.Content = _myBillsManager.HowMuchBillsCreated(false); LblShippingTimeNumber.Content = _globalConfig.ShippingTime; if (_globalConfig.LastShipmentWithErrors == "yes") { LblStatusLastShippingValue.Content = "No OK"; LblStatusLastShippingValue.Foreground = Brushes.Red; } else { LblStatusLastShippingValue.Content = "OK"; LblStatusLastShippingValue.Foreground = Brushes.Green; } })); }