private async Task <Fact> RequestVariable(Variable variable) { BeginInvoke(new Action(() => { listViewQuestion.Items.Add(new ListViewItem() { Text = variable.Question, SubItems = { string.Empty } }); comboBoxAnswers.Items.Clear(); foreach (var domain in variable.Domain.Values) { comboBoxAnswers.Items.Add(domain); } comboBoxAnswers.SelectedIndex = 0; comboBoxAnswers.Enabled = true; buttonAnswer.Enabled = true; })); await _semaphoreSlim.WaitAsync(); IndexedNamedItem factValue = null; var asyncResult = BeginInvoke(new Action(() => factValue = (IndexedNamedItem)comboBoxAnswers.SelectedItem)); asyncResult.AsyncWaitHandle.WaitOne(); return(new Fact() { Variable = variable, Value = factValue }); }
private void ButtonAddClick(object sender, EventArgs e) { TrySetIndexedNamedItem(() => { var domainValue = new IndexedNamedItem(textBoxValue.Text); _domain.Values.Add(domainValue); listBoxValues.Items.Add(domainValue); listBoxValues.SelectedIndex = -1; textBoxValue.Text = string.Empty; }); }