From 2c11c39ff0fe6671bea466ea0a377383245ee5d3 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 13 Sep 2022 09:42:38 -0400 Subject: [PATCH] rearrange order of OnBeforeShutdown and OnStopping - why are there two of these? --- MBS.Framework/Application.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MBS.Framework/Application.cs b/MBS.Framework/Application.cs index 9438d23..fce83cb 100644 --- a/MBS.Framework/Application.cs +++ b/MBS.Framework/Application.cs @@ -493,17 +493,19 @@ namespace MBS.Framework Stopping = true; System.ComponentModel.CancelEventArgs ce = new System.ComponentModel.CancelEventArgs(); - OnStopping(ce); - if (ce.Cancel) - return; - - ce = new System.ComponentModel.CancelEventArgs(); OnBeforeShutdown(ce); if (ce.Cancel) { return; } + ce = new System.ComponentModel.CancelEventArgs(); + + // OnStopping called after setting Stopping to True, otherwise there is no real difference + OnStopping(ce); + if (ce.Cancel) + return; + StopInternal(exitCode); OnShutdown(EventArgs.Empty);