I have a method of a web service that receives the IP of a server as a parameter and returns a DataSet
. Multiple servers must be queried by this web service, A List<string>
contains the list of IPs. A loop executes the method, a merge is returned to a local DataSet, and then a% winforms is populated with that data.
The code that does this is simple:
foreach (var server in servers)
{
ds.Merge(ws.GetData(server));
}
dataGridView1.DataSource = ds.Tables[0];
This call runs in a queue and takes a while to finish, in addition to locking the entire form.
How can I convert this process to an asynchronous form using the DataGridView
method with GetDataAsync
and async
to execute all calls at once and display the data in Task
at the end?