From 9f59c21f51d538dc537a3d5cbfd7aff3d957d207 Mon Sep 17 00:00:00 2001 From: Antony Male Date: Tue, 27 May 2014 13:28:50 +0100 Subject: [PATCH] Fix bug where Stylet would launch before resources were loaded --- Stylet/Bootstrapper.cs | 6 +++--- Stylet/BootstrapperBase.cs | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Stylet/Bootstrapper.cs b/Stylet/Bootstrapper.cs index 51bea9a..36cc7ca 100644 --- a/Stylet/Bootstrapper.cs +++ b/Stylet/Bootstrapper.cs @@ -16,14 +16,14 @@ namespace Stylet public class Bootstrapper : BootstrapperBase where TRootViewModel : class { /// - /// Create a new Bootstrapper, which automatically starts and launches + /// Create a new Bootstrapper, which automatically starts and launches on application startup /// public Bootstrapper() : base() { } /// - /// Create a new Bootstrapper, and specify whether to auto-start and auto-launhc + /// Create a new Bootstrapper, and specify whether to auto-start and auto-launch /// - /// True to call this.Start() at the end of this constructor + /// True to call this.Start() on Application.Startup. If false, call this.Start() in your OnStartup override public Bootstrapper(bool autoStart) : base(autoStart) { } /// diff --git a/Stylet/BootstrapperBase.cs b/Stylet/BootstrapperBase.cs index c22d731..8a00323 100644 --- a/Stylet/BootstrapperBase.cs +++ b/Stylet/BootstrapperBase.cs @@ -24,7 +24,7 @@ namespace Stylet protected Application Application { get; private set; } /// - /// Create a new BootstrapperBase, which automatically start + /// Create a new BootstrapperBase, which automatically starts on application startup /// public BootstrapperBase() : this(true) { } @@ -40,15 +40,17 @@ namespace Stylet // Allows for unit testing if (this.Application != null) { - this.Application.Startup += this.OnStartup; + this.Application.Startup += (o, e) => + { + this.OnStartup(o, e); + if (autoStart) + this.Start(); + }; // Make life nice for the app - they can handle these by overriding Bootstrapper methods, rather than adding event handlers this.Application.Exit += OnExit; this.Application.DispatcherUnhandledException += OnUnhandledExecption; } - - if (autoStart) - this.Start(); } ///