Suppose I implement an interface where there are two methods: Create
and CreateAsync
. The Async method in my case is not really async, and it uses the syncronous Create
method to return the created object:
public Task<GrandeurDTO> CreateAsync()
{
var dto = Create();
return Task.FromResult(dto);
}
public GrandeurDTO Create()
{
var bo = new Grandeur();
var dto = _mapper.Map<GrandeurDTO>(bo);
return dto;
}
How should I remove the warning
This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(CS1998)
knowing I can't rename the method in Create
(I already have one; cause if not the question is similar to this one )
我相信这只是一个疲惫的 Visual Studio 的情况,并且 1)重新编译或 2)VS 重新启动将解决这个问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.