且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

等待操作符只能在异步方法中使用

更新时间:2021-11-30 21:13:59

***方法是使方法async生效,因为编译器错误指示:

The best approach is to make the method async, as the compiler error indicates:

public async Task<Stream> CreateSerialPortStreamAsync(string serialPortName)

这也需要更改界面:

Task<Stream> CreateSerialPortStreamAsync(string serialPortName);

是的,此方法的所有调用方都需要更新.

And yes, all callers of this method will need to be updated.