Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AppWindow.cs
1using System;
2using System.Threading.Tasks;
3using Microsoft.Maui;
4using Microsoft.Maui.Controls;
6
7namespace NeuroAccessMaui.UI
8{
12 internal sealed class AppWindow : Window
13 {
14 private readonly App app;
15 private readonly IActivationState? activationState;
16
23 public AppWindow(App app, Page rootPage, IActivationState? activationState)
24 : base(rootPage)
25 {
26 this.app = app;
27 this.activationState = activationState;
28 }
29
31 protected override void OnCreated()
32 {
33 base.OnCreated();
34 this.app.HandleWindowCreated(this.activationState);
35 }
36
38 protected override void OnStopped()
39 {
40 base.OnStopped();
41 this.FireAndForget(this.app.HandleWindowStoppedAsync);
42 }
43
45 protected override void OnResumed()
46 {
47 base.OnResumed();
48 this.FireAndForget(this.app.HandleWindowResumedAsync);
49 }
50
52 protected override void OnDestroying()
53 {
54 base.OnDestroying();
55 this.FireAndForget(this.app.HandleWindowDestroyingAsync);
56 }
57
58 private void FireAndForget(Func<Task> lifecycleHandler)
59 {
60 _ = Task.Run(async () =>
61 {
62 try
63 {
64 await lifecycleHandler().ConfigureAwait(false);
65 }
66 catch (Exception ex)
67 {
68 this.ReportLifecycleException(ex);
69 }
70 });
71 }
72
73 private void ReportLifecycleException(Exception ex)
74 {
75 try
76 {
77 ServiceRef.LogService.LogException(ex);
78 }
79 catch
80 {
81 System.Diagnostics.Debug.WriteLine(ex);
82 }
83 }
84 }
85}
Represents an instance of the Neuro-Access app.
Definition: App.xaml.cs:125
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
Definition: ImplTypes.g.cs:58