CHAPTER 19 MULTITHREADED, PARALLEL, AND ASYNC PROGRAMMING
Figure 19-5. Methods that return a Task object are able to be called via await
Given the fact that methods that return Task objects can now be called in a nonblocking manner via
the async and await tokens, Microsoft recommends (as a best practice) that any method returning a Task
be marked with an “Async” suffix. In this way, developers who know the naming convention receive a
visual reminder that the await keyword is required, if they intend to invoke the method within an
asynchronous context.
Note Event handlers for GUI controls (such as our button Click handler) that use the async / await keywords
do not follow this naming convention (by convention—pardon the redundancy!).
Furthermore, the DoWork() method could also be decorated with the async and await tokens
(although this is not strictly required for the current example). Given these points, here is the final
update to the current example, which conforms to the recommending naming conventions:
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
747