I am trying to use Async and Await to enable a task only when a button disable event has completed.
I tried using:
protected async void btnStart_Click(object sender, EventArgs e)
{
tskDisabled = DisableButton();
int result = await tskDisabled;
if (result == 1)
FilesCount();
}
private async Task<int> DisableButton()
{
btnStart.Enabled = false;
await Task.Delay(1000);
return 1;
}
I want to start the FilesCount() method only when the button btnStart is disabled.
At present, the task starts but button remains enabled.