private async Task Close() { await CancelSearch(); Symbol = string.Empty; Contracts_List.Clear(); IsVisible = false; }
private async Task StartSearch(string smb) { IsSearchingInProgress = true; Contracts_List.Clear(); List <ContractDetails> contractDetailsList; if (string.IsNullOrEmpty(smb)) { contractDetailsList = TwsData.DataFeeder.GetContractDetailsList(new ContractData() { Symbol = this.Symbol, SecType = "STK" }); } else { contractDetailsList = TwsData.DataFeeder.GetContractDetailsList(new ContractData() { Symbol = smb, SecType = "STK" }); } foreach (ContractDetails cd in contractDetailsList) { ContractDetails_ViewModel contractVM = new ContractDetails_ViewModel(cd); await dispatcher.InvokeAsync(() => Contracts_List.Add(contractVM)); contractVM.EndPriceUpdate_Event += ContractVM_EndPriceUpdate_Event; Thread t = new Thread(new ThreadStart(contractVM.StartDownloadData)); t.Start(); lock (countContractsUpdating_lock) { ++countContractsUpdating; } } }
// // Double click on contract will fire up ContractSelected_Event (to AddSymbol_ViewModel) // private async Task leftDoubleClicked() { if (SelectedReqId <= 0) { return; } ContractDetails_ViewModel contractVM = Contracts_List.FirstOrDefault(c => c.ReqId == SelectedReqId); if (contractVM.IsEnabled == false) { return; } // First cancel others ContractDetails requests foreach (ContractDetails_ViewModel cdVm in Contracts_List) { cdVm.CancelPriceUpdate(); } ContractSelected_Event?.Invoke(this, new ContractDetailsRecv_EventArgs(SelectedReqId, contractVM.ContractDetails)); await Close(); }