// An event is the only type of void that can be async private async void BtnAsyncClicked(object sender, EventArgs e) { ClearScreen(); Stopwatch watch = Stopwatch.StartNew(); await Method1Async(); await Method2Async(); await Method3Async(); await Method4Async(); EnergizerBunny bunny = await GetBunnyAsync(); TxtResult.Text += bunny.ToString(); TxtResult.Text += $"{Environment.NewLine}Elapsed time: {watch.ElapsedMilliseconds}"; }
private void BtnSyncClicked(object sender, EventArgs e) { ClearScreen(); Stopwatch watch = Stopwatch.StartNew(); Method1(); Method2(); Method3(); Method4(); EnergizerBunny bunny = GetBunny(); TxtResult.Text += bunny.ToString(); TxtResult.Text += $"{Environment.NewLine}Elapsed time: {watch.ElapsedMilliseconds}"; }