Tag: asynchronous

C# some detailed questions of “async and await”

问题内容: private async void btnCallMethod_Click(object sender, EventArgs e) { this.Text = await DoWorkAsync(); for (int i = 1; i <= 2; i++) { MessageBox.Show($"Inside of btnCallMethod_Click() invoked after DoWorkAsync() finished: {i.ToString()}"); Thread.Sleep(1000); } } private async void btnVoidMethodCall_Click(object sender, EventArgs e) { await ForBy2ndButton(); } private async Task ForBy2ndButton() { await Task.Run(() => { for