Asynchronous execution patterns
Tasks are generally used to create an easy sequential execution for asynchronous blocks. Nevertheless, in certain scenarios, waiting for a task to complete might be unnecessary or not possible. We can enumerate a couple of scenarios where awaiting a task is not possible or required:
- If we are executing the asynchronous block, similar to the update user command, we would simply bind the command to the control and execute it in a throw-and-forget manner.
- If our asynchronous block needs to be executed in a constructor, we will have no easy way to await the task.
- If the asynchronous code needs to be executed as part of an event handler.
Multiple examples can be listed here regarding common concerns, such as the following:
- Method declaration should not exhibit the
async
andvoid
return types. - Methods should not be forced to execute synchronously with the
Wait
method or theResult
property. - Methods that are dependent...