void Instance_handleStockPriceUpdated(object sender, StockPriceUpdateEventArgs e) { try { new Thread((ThreadStart) delegate() { this.BeginInvoke((ThreadStart) delegate() { try { //find the stock price in the list int i = AllRealTimePositions.Find("Cusip", e.StockPrice.Cusip); if (i != -1) { //update the stock AllRealTimePositions[i].Price = e.StockPrice.Price; } dgvRealTimePosition.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex, TraceEnum.LoggedError); } }); }).Start(); } catch (Exception ex) { Trace.WriteLine(ex, TraceEnum.LoggedError); } }
protected virtual void OnStockPriceUpdated(StockPriceUpdateEventArgs e) { if (handleStockPriceUpdated != null) { handleStockPriceUpdated(this, e); } }