Support for the asynchronous programming model in Caliburn.Micro is now very good.
A few things you can do:
- Use async / await in an action method . Be careful, since action methods are technically event handlers, you are shoud do
async void , not async Task . - Asynchronous event handlers for screen events , for example, Activated, ViewLoaded, and others.
- Asynchronous overrides for screen methods : OnInitialize, OnActivate, ... You can then override it as
protected override async void OnInitialize(){} , and inside you can wait for another task. - Convert Coroutines to Tasks . Use the
ExecuteAsync() extension method. In some scenarios, Coroutines has some advantages, such as an execution context. IHandleWithTask<TMessage> - quite convenient ...
There 's a blog post describing some use cases , with a few snippets of code. And the GitHub repository with a sample project I played with asynchronous / wait in Caliberna.
source share