Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在调用一个同步的库方法。我想使用新功能async和await功能,但我不确定如何,因为库不支持异步(不返回任务)。
async
await
有没有办法做到这一点,或者我需要构建一个包装器来做什么?
您可以在后台线程中运行同步代码,方法是在Task.Run.
Task.Run
像这样的东西?
using System.Threading.Tasks; new Task<bool>(() => { // Do something return true; }).Start();