diff --git a/src/Caliburn.Micro.Core/ResultCompletionEventArgs.cs b/src/Caliburn.Micro.Core/ResultCompletionEventArgs.cs
index e6e86b19..457ed3d7 100644
--- a/src/Caliburn.Micro.Core/ResultCompletionEventArgs.cs
+++ b/src/Caliburn.Micro.Core/ResultCompletionEventArgs.cs
@@ -18,5 +18,12 @@ public class ResultCompletionEventArgs : EventArgs
///
/// true if cancelled; otherwise, false.
public bool WasCancelled;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ResultCompletionEventArgs()
+ {
+ }
}
}
diff --git a/src/Caliburn.Micro.Core/Screen.cs b/src/Caliburn.Micro.Core/Screen.cs
index 80c68f65..5b6ba43f 100644
--- a/src/Caliburn.Micro.Core/Screen.cs
+++ b/src/Caliburn.Micro.Core/Screen.cs
@@ -103,20 +103,35 @@ async Task IActivate.ActivateAsync(CancellationToken cancellationToken)
if (!IsInitialized)
{
+ try
+ {
+ Log.Info("Initializing {0}.", this);
#pragma warning disable CS0618 // Type or member is obsolete
- await OnInitializeAsync(cancellationToken);
+ await OnInitializeAsync(cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
- IsInitialized = initialized = true;
- await OnInitializedAsync(cancellationToken);
+ IsInitialized = initialized = true;
+ await OnInitializedAsync(cancellationToken);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex);
+ OnInitializedAsyncException(ex);
+ }
}
-
- Log.Info("Activating {0}.", this);
+ try
+ {
+ Log.Info("Activating {0}.", this);
#pragma warning disable CS0618 // Type or member is obsolete
- await OnActivateAsync(cancellationToken);
+ await OnActivateAsync(cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
- IsActive = true;
- await OnActivatedAsync(cancellationToken);
-
+ IsActive = true;
+ await OnActivatedAsync(cancellationToken);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex);
+ OnActivatedAsyncException(ex);
+ }
await (Activated?.InvokeAllAsync(this, new ActivationEventArgs
{
WasInitialized = initialized
@@ -134,7 +149,16 @@ async Task IDeactivate.DeactivateAsync(bool close, CancellationToken cancellatio
});
Log.Info("Deactivating {0}.", this);
- await OnDeactivateAsync(close, cancellationToken);
+ try
+ {
+ await OnDeactivateAsync(close, cancellationToken);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex);
+ OnDeactivateAsyncException(ex);
+ }
+
IsActive = false;
await (Deactivated?.InvokeAllAsync(this, new DeactivationEventArgs
@@ -206,6 +230,15 @@ protected virtual Task OnActivateAsync(CancellationToken cancellationToken)
}
+ ///
+ /// Called when exception called in OnActivatedAsync.
+ ///
+ protected virtual void OnActivatedAsyncException(Exception thrownException)
+ {
+ Log.Info("Activated Async Exception");
+ Log.Error(thrownException);
+ }
+
///
/// Called when view has been activated.
///
@@ -226,5 +259,23 @@ protected virtual Task OnDeactivateAsync(bool close, CancellationToken cancellat
Log.Info("Task deactivate");
return Task.FromResult(true);
}
+
+ ///
+ /// Called when exception called in OnDectivateAsync.
+ ///
+ protected virtual void OnDeactivateAsyncException(Exception thrownException)
+ {
+ Log.Info("Deactivate Async Exception");
+ Log.Error(thrownException);
+ }
+
+ ///
+ /// Called when exception called in OnInitializedAsync.
+ ///
+ protected virtual void OnInitializedAsyncException(Exception thrownException)
+ {
+ Log.Info("Initialized Async Exception");
+ Log.Error(thrownException);
+ }
}
}
diff --git a/src/Caliburn.Micro.Platform/Platforms/Android/CaliburnApplication.cs b/src/Caliburn.Micro.Platform/Platforms/Android/CaliburnApplication.cs
index 371de01a..61b78f65 100644
--- a/src/Caliburn.Micro.Platform/Platforms/Android/CaliburnApplication.cs
+++ b/src/Caliburn.Micro.Platform/Platforms/Android/CaliburnApplication.cs
@@ -21,7 +21,7 @@ public class CaliburnApplication : Application
public CaliburnApplication(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
-
+
}
///
@@ -41,7 +41,7 @@ protected virtual void StartDesignTime()
///
/// Called by the bootstrapper's constructor at runtime to start the framework.
- /// B
+ ///
protected virtual void StartRuntime()
{
AssemblySourceCache.Install();
@@ -131,5 +131,14 @@ protected virtual IEnumerable