private async void SelectAttribute_Load(object sender, EventArgs e) { using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool, out List <ListItem> lstAttributes)) { // Build the list of Attributes. foreach (string strAbbrev in _lstAttributeAbbrevs) { string strAttributeDisplayName = strAbbrev == "MAGAdept" ? await LanguageManager.MAGAdeptStringAsync() : await LanguageManager.GetStringAsync("String_Attribute" + strAbbrev + "Short"); lstAttributes.Add(new ListItem(strAbbrev, strAttributeDisplayName)); } await cboAttribute.PopulateWithListItemsAsync(lstAttributes); if (lstAttributes.Count >= 1) { await cboAttribute.DoThreadSafeAsync(x => x.SelectedIndex = 0); } else if (lstAttributes.Count == 0) { await cmdOK.DoThreadSafeAsync(x => x.Enabled = false); } else { _strReturnValue = await cboAttribute.DoThreadSafeFuncAsync(x => x.SelectedValue.ToString()); DialogResult = DialogResult.OK; } } }
private async void SelectAttribute_Load(object sender, EventArgs e) { using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool, out List <ListItem> lstAttributes)) { // Build the list of Attributes. foreach (string strAbbrev in _lstAttributeAbbrevs) { string strAttributeDisplayName = strAbbrev == "MAGAdept" ? await LanguageManager.MAGAdeptStringAsync() : await LanguageManager.GetStringAsync("String_Attribute" + strAbbrev + "Short"); lstAttributes.Add(new ListItem(strAbbrev, strAttributeDisplayName)); } await cboAttribute.PopulateWithListItemsAsync(lstAttributes); if (lstAttributes.Count >= 1) { cboAttribute.SelectedIndex = 0; } else if (lstAttributes.Count == 0) { cmdOK.Enabled = false; } else { cmdOK_Click(sender, e); } } }