I have a method void getInformation()
that calls 5 other methods of which each is getting some data from a database. It takes about 1 second until all data is collected and returned to getInformation()
and because of that I thought I should collect the data in the background. My question is: can I just make getInformation()
async
so the UI isn't blocked while the other methods are collecting the information or do I have to make every of the other methods async
?
private void button_Click(object sender, EventArgs e)
{
await getContactInformation();
}
public async Task getContactInformation()
{
this.data.Add(collectData1());
this.data.Add(collectData2());
this.data.Add(collectData3());
this.data.Add(collectData4());
this.data.Add(collectData5());
}