From c275c017c14c66399ad03386f2e8f52faf4d6fd1 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 21 Jul 2024 22:35:30 -0400 Subject: [PATCH] add BeforeStartInternal event --- framework-dotnet/src/lib/MBS.Core/Application.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/framework-dotnet/src/lib/MBS.Core/Application.cs b/framework-dotnet/src/lib/MBS.Core/Application.cs index 024c65c..2a84844 100644 --- a/framework-dotnet/src/lib/MBS.Core/Application.cs +++ b/framework-dotnet/src/lib/MBS.Core/Application.cs @@ -1,4 +1,6 @@ -namespace MBS.Core; +using System.ComponentModel; + +namespace MBS.Core; public class Application { @@ -25,9 +27,21 @@ public class Application return e.ExitCode; } + public event EventHandler BeforeStartInternal; + protected virtual void OnBeforeStartInternal(CancelEventArgs e) + { + BeforeStartInternal?.Invoke(this, e); + } + public int Start() { Instance = this; + + CancelEventArgs e = new CancelEventArgs(); + OnBeforeStartInternal(e); + if (e.Cancel) + return 2; + int exitCode = StartInternal(); Instance = null;