/// <summary> /// Handles the RunWorkerCompleted event of the bckgrndWrkrGetPrices control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.RunWorkerCompletedEventArgs"/> instance containing the event data.</param> private void bckgrndWrkrGetPrices_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { ExceptionHandler.LogException(e.Error, true); MessageBox.Show($"Failed to retrieve mineral pricing data:\n{e.Error.Message}", @"Failed to Retrieve Data", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } else { IDictionary <string, Decimal> prices = e.Result as IDictionary <string, Decimal>; if (prices == null) { return; } foreach (MineralTile mt in Tiles) { mt.PricePerUnit = prices.ContainsKey(mt.MineralName) ? prices[mt.MineralName] : 0m; } tslCourtesy.Text = $"Mineral Prices Courtesy of {MineralDataRequest.GetCourtesyText(m_source)}"; m_courtesyUrl = MineralDataRequest.GetCourtesyUrl(m_source).AbsoluteUri; tslCourtesy.Visible = true; } }
private void bckgrndWrkrGetPrices_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { ExceptionHandler.LogException(e.Error, true); MessageBox.Show(String.Format("Failed to retrieve mineral pricing data:\n{0}", e.Error.Message), "Failed to Retrieve Data", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { IDictionary <string, Decimal> prices = e.Result as IDictionary <string, Decimal>; if (prices != null) { foreach (MineralTile mt in Tiles) { if (prices.ContainsKey(mt.MineralName)) { mt.PricePerUnit = prices[mt.MineralName]; } } tslCourtesy.Text = String.Format("Mineral Prices Courtesy of {0}", MineralDataRequest.GetCourtesyText(m_source)); m_courtesyUrl = MineralDataRequest.GetCourtesyUrl(m_source); tslCourtesy.Visible = true; } } }