Beispiel #1
0
 /// <summary>
 /// Update the observable collection
 /// </summary>
 /// <param name="historicStock"></param>
 private void UpdateDataCollection(List <HistoricPrice> historicStock)
 {
     if (historicStock.Any())
     {
         historicStock.ForEach(historicItem => HistoricStockPrices.Add(historicItem));
     }
 }
Beispiel #2
0
        /// <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");
        }
Beispiel #3
0
        /// <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();
        }