Skip to content

Commit 7a45013

Browse files
committed
Activated event handler must be async in Caliburn.Micro 5
1 parent edefb87 commit 7a45013

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/ServiceControl.Config/Framework/Rx/RxScreen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class RxScreen : RxViewAware, IScreen, IChild, IModalResult
3737
/// <summary>
3838
/// Raised after activation occurs.
3939
/// </summary>
40-
public event EventHandler<ActivationEventArgs> Activated = (sender, e) => { };
40+
public event AsyncEventHandler<ActivationEventArgs> Activated = (sender, e) => Task.CompletedTask;
4141

4242
public IEventAggregator EventAggregator { get; set; }
4343

@@ -70,7 +70,7 @@ async Task IActivate.ActivateAsync(CancellationToken cancellationToken)
7070
Log.Info("Activating {0}.", this);
7171
await OnActivate();
7272

73-
Activated(this, new ActivationEventArgs
73+
await Activated(this, new ActivationEventArgs
7474
{
7575
WasInitialized = initialized
7676
});

src/ServiceControl.Config/Framework/Rx/RxViewAware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Threading.Tasks;
56
using Caliburn.Micro;
67

78
public class RxViewAware : RxPropertyChanged, IViewAware
@@ -61,7 +62,7 @@ public virtual object GetView(object context = null)
6162
static void AttachViewReadyOnActivated(IActivate activatable, object nonGeneratedView)
6263
{
6364
var viewReference = new WeakReference(nonGeneratedView);
64-
EventHandler<ActivationEventArgs> handler = null;
65+
AsyncEventHandler<ActivationEventArgs> handler = null;
6566
handler = (s, e) =>
6667
{
6768
((IActivate)s).Activated -= handler;
@@ -70,6 +71,8 @@ static void AttachViewReadyOnActivated(IActivate activatable, object nonGenerate
7071
{
7172
PlatformProvider.Current.ExecuteOnLayoutUpdated(view, ((RxViewAware)s).OnViewReady);
7273
}
74+
75+
return Task.CompletedTask;
7376
};
7477
activatable.Activated += handler;
7578
}

0 commit comments

Comments
 (0)