Edit: My original answer did not address the post's real question.
There's another post related to this about returning null
versus an empty object: Should functions return null or an empty object?
Returning null is usually the best idea if you intend to indicate that
no data is available.
An empty object implies data has been returned, whereas returning null
clearly indicates that nothing has been returned.
Additionally, returning a null will result in a null exception if you
attempt to access members in the object, which can be useful for
highlighting buggy code - attempting to access a member of nothing
makes no sense. Accessing members of an empty object will not fail
meaning bugs can go undiscovered.
However, if it was ever not ok for _id
to be null
then throwing an exception would probably be the better solution since it would help you gracefully handle bugs in the logic and also allow you to add logging.
Microsoft also has some great documentation on on asynchronous programming in general. I would take a look at this article here: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/task-asynchronous-programming-model, particularly this part:
If you specify that a method is an async method by using the async modifier, you enable the following two capabilities.
- The marked async method can use await to designate suspension points. The await operator tells the compiler that the async method can't continue past that point until the awaited asynchronous process is complete. In the meantime, control returns to the caller of the async method.
The suspension of an async method at an await expression doesn't constitute an exit from the method, and finally blocks don't run.
- The marked async method can itself be awaited by methods that call it.
An async method typically contains one or more occurrences of an await operator, but the absence of await expressions doesn't cause a compiler error. If an async method doesn't use an await operator to mark a suspension point, the method executes as a synchronous method does, despite the async modifier. The compiler issues a warning for such methods.