Reputation: 2783
If I run this code, will editButton
wait to become enabled until my (asynchronous) getMachines()
function has finished running? If not, how do I create this functionality?
editButton.isEnabled = false;
loadedMachines = await azureService.GetMachines();
editButton.isEnabled = true;
Upvotes: 1
Views: 51
Reputation: 495
Yes, await keyword will make your thread wait for the response.
Don't forget to add async keywork on your method and to return a Task<> in GetMachines()
Upvotes: 1
Reputation: 497
Yes edit button will wait for upper functionality to finish first.
Upvotes: 2