为什么不将该方法作为异步任务调用?

时间:2015-09-10 11:31:03

标签: c# asynchronous task-parallel-library

我有这段代码:

private async void WaitAnyAll(object sender, EventArgs e)
{
    var start = new Task(() => { StartAll("Starter"); } );

    textBox1.Text += "Before" + Environment.NewLine;
    start.Start();
    textBox1.Text += "End" + Environment.NewLine;
}

private async Task StartAll(string mssg)
{
    textBox1.Text += mssg + Environment.NewLine;
}

哪个输出(在文本TextBox控件中):

Before
End

但我确定应该输出这个:

Before
End
Starter

为什么不这样做?

0 个答案:

没有答案