private void QuoteManager_onQuoteServiceSwitchChanged(object sender, QuoteServiceSwitchChangedEvent e) { string sDataSource = e.DataSource; if (e.IsRunning) { bool bNotHave = false; lock (__cDataSources) { if (!__cDataSources.Contains(sDataSource)) { __cDataSources.Add(sDataSource); bNotHave = true; } } if (bNotHave) { AbstractQuoteService cService = QuoteManager.Manager.GetQuoteService(sDataSource); cService.onQuote += QuoteService_onQuote; cService.onSubscribeCompleted += QuoteService_onCompleted; cService.onComplementCompleted += QuoteService_onCompleted; } } else { lock (__cDataSources) { __cDataSources.Remove(sDataSource); } } }
private void QuoteManager_onQuoteServiceSwitchChanged(object sender, QuoteServiceSwitchChangedEvent e) { if (e.IsRunning) { //如果使用者開啟了即時報價資訊源 this.SetQuoteService(e.DataSource); //設定即時報價資訊源 } else { //如果使用者關閉了即時報價資訊源 string sDataSource = e.DataSource; //取得報價資料來源名稱 lock (__cDataSources) { if (__cDataSources.Contains(sDataSource)) { //如果有報價資料來源 __cDataSources.Remove(sDataSource); //移除報價資料來源名稱 } } } }