C# 解决async Task<object>直接执行返回报“CS1998”警告
问题描述:
public async Task<bool> Login(string account, string password)
{
return true;
}
此方法报:
CS1998;此异步方法缺少"await"运算符,将以同步方式运行。请考虑使用"await”"运算符等待非阻止的API调用,或者使用"await TaskRun(…)”在后台线程上执行占用大量CPU的工作。
解决方法:
public async Task<bool> Login(string account, string password)
{
return await Task.FromResult(true);
}
关键字:
Task.FromResult(object);
原文链接:https://blog.csdn.net/asd497907957/article/details/127401076
public async Task<bool> Login(string account, string password)
{
return true;
}
此方法报:
CS1998;此异步方法缺少"await"运算符,将以同步方式运行。请考虑使用"await”"运算符等待非阻止的API调用,或者使用"await TaskRun(…)”在后台线程上执行占用大量CPU的工作。
解决方法:
public async Task<bool> Login(string account, string password)
{
return await Task.FromResult(true);
}
关键字:
Task.FromResult(object);
原文链接:https://blog.csdn.net/asd497907957/article/details/127401076
本站大部分文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。
如果侵犯了您的权益请来信告知我们删除。邮箱:1451803763@qq.com