I have a interface which exposes some async methods. More specifically it has methods defined which return either Task
or Task<T>
. I am using the async/await keywords.
I am in the process of implementing this interface. However, in some of these methods this implementation doesn't have anything to await. For that reason I am getting the compiler warning "CS1998: This async method lacks 'await' operators and will run synchronously..."
I understand why I am getting these warnings but am wondering whether I should do anything about them in this context. It feels wrong to ignore compiler warnings.
I know I can fix it by awaiting on Task.Run
but that feels wrong for a method that is only doing a few inexpensive operations. It also sounds like it will add unneeded overhead to the execution but then I am also not sure if that is already there because the async
keyword is present.
Should I just ignore the warnings or is there a way of working around this that I am not seeing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…