/// <summary> /// background work completed event handler /// </summary> /// <param name="sender"></param> /// <param name="runWorkEventArgs"></param> void bgworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs runWorkEventArgs) { var stockListResults = runWorkEventArgs.Result as List <HistoricPrice>; UpdateDataCollection(stockListResults); RowCount = HistoricStockPrices.Count(); ViewModelHelper.ShowMessage(HistoricStockPrices.Any()? string.Format("{0} Rows Loaded Successfully", RowCount) : "No data found, Please modify the search paramaters and try again.", "Info"); }
/// <summary> /// Get Data asynchronously /// </summary> private void GetPricesAsync() { //clear the observable collection HistoricStockPrices.Clear(); RowCount = HistoricStockPrices.Count(); //start a new background thread var bgworker = new BackgroundWorker(); bgworker.DoWork += GetPrices; bgworker.RunWorkerCompleted += bgworker_RunWorkerCompleted; bgworker.RunWorkerAsync(); }