Skip to content

Recommended pattern after Activated changed to AsyncEventHandler in v5 #1063

Description

@siebe1996

Hi,
In previous versions of Caliburn.Micro, I used the Activated event to start loading data after a screen/dialog was activated. Since Activated was an EventHandler, I could use an async void event handler and allow the dialog to appear immediately while the data loaded in the background.
In v5 #763 , Activated changed from:
public event EventHandler<ActivationEventArgs> Activated;Show more lines
to:
public event AsyncEventHandler<ActivationEventArgs> Activated;Show more lines
This changes the behavior of the pattern I was previously using.
I found issue #773 where OnInitializeAsync is recommended as the place to load data. However, when I open a dialog using IWindowManager.ShowDialogAsync, the dialog is not displayed until the data loading has completed. The behavior I had before was that the dialog became visible immediately and the data loaded afterwards.
What is the recommended pattern in v5 for scenarios where a dialog opened via IWindowManager.ShowDialogAsync should become visible immediately and data loading should not block the dialog from being shown?
I'm not looking for a workaround, but rather for guidance on the intended/recommended approach now that Activated is asynchronous.
Thanks.

Activity

  1. LWChris commented on Aug 31, 2026

    @LWChris
    Contributor

    Not sure about CM, but the usual way to trigger some async function that you are not interested in awaiting is _ = Task.Run(TheAsyncMethod); which works from synchronous and asynchronous contexts alike. The only difficulty is, much like with async void, you have to deal with the exceptions from within the called method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions