【发布时间】:2020-02-26 01:23:04
【问题描述】:
使用 asyn/await 与 await task.run() 有什么区别
等待 task.run 示例 -
public static void Main()
{
await Task.Run(() =>
{
return "Good Job";
});
method1();
method2();
}
异步等待示例-
public static async void Launch()
{
await GetMessage();
Method1();
Method2();
}
public static async Task<string> GetMessage()
{
//Do some stuff
}
【问题讨论】:
-
此资源可能会有所帮助:stackoverflow.com/questions/38739403/…
标签: c# .net async-await task-parallel-library