Implementing asynchronous commands
As you may know, .NET MAUI runs all UI-related operations in a single UI thread. However, your application may require executing long-running commands, such as loading data from a remote server, reading a large file, generating a report, etc. By default, commands are executed in the UI thread, meaning that when a command is running, the UI will be frozen. A good practice for user experience is not to block the UI when such a command is executed.
You can create tasks or even separate threads manually, but the Community Toolkit allows you to easily achieve the goal with asynchronous commands. It allows you to automatically track the command execution state or cancel the command.
Getting ready
Start with the project you got after executing the second recipe of this chapter: Implementing auto-generated view model properties. This project is available at https://github.com/PacktPublishing/.NET-MAUI-Cookbook/tree/main/Chapter02/c2-GeneratedViewModels...