110,538
社区成员
发帖
与我相关
我的任务
分享
private async void button1_Click(object sender, EventArgs e)
{
try
{
await DoSomethingAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private async Task DoSomethingAsync()
{
await Task.Run(() =>
{
Thread.Sleep(3000);
throw new Exception("Test");
});
}
Task<int> t=null;
if (t.Exception != null)
{
throw t.Exception;
}