I have a combo box of cities that populate it every time I start my form. I would like someone to help me create an asynchronous method using SqlDataAdapter
to fill this combo.
I have a combo box of cities that populate it every time I start my form. I would like someone to help me create an asynchronous method using SqlDataAdapter
to fill this combo.
Without further details about the current implementation and the real need to fill the combo asynchronously, it is difficult to try to help. If you give more details, I can tailor the answer to your case.
I imagine that's what you're looking for:
private void QualquerForm_Shown(object sender, EventArgs e)
{
await PreencheCombo();
}
private Task PreencheCombo()
{
return Task.Factory.StartNew(() =>
{
Invoke(new MethodInvoker(() => cbCidades.DataSource = Cidades.FindAll()));
});
}