I\'ve just stumbled across a rather dangerous scenario while migrating an ASP.NET application to the async/await model.
The situation is that I made a method async:
The compiler will emit warning CS4014 but it is only emitted if the calling method is async.
No warning:
Task CallingMethod() {
DoWhateverAsync();
// More code that eventually returns a task.
}
Warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
async Task CallingMethod() {
DoWhateverAsync();
}
This is not terrible useful in your specific case because you have to find all the places where DoWhateverAsync is called and change them to get the warning and then fix the code. But you wanted to use the compiler warning to find these calls in the first place.
I suggest that you use Visual Studio to find all usages of DoWhateverAsync. You will have to modify the surrounding code anyway either by going through compiler warnings or by working through a list of usages.