In C#, when we call an async method, it is needed to await it within the method, or the compiler will give out a warning message saying the method will be called sync without "await". I know this is useful in scenarios like:
var task = DoSomethingLongAsync(); DoSomethingElse(); await task; That is because when we call that async method, we can do something else, then wait for the async result.
But in some other cases, we don't need to wait the async result, like the scenario similar to web server:
listen(); while (true) { var request = Accept(); await ProcessRequestAsync(request); } Obviously, for above scenario, we hope the requests can be processed in parallel. But if we use await there (as current), the requests will be processed one by one, not as we expected.
So how should we call async methods in similar scenarios?
Acceptmethod? Is it a blocking method?