protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; hwndSource.AddHook(WndProc); TimeMerge.App app = Application.Current as TimeMerge.App; if (app.Context.MinimizedStartupRequested) { minimizeWindow(); } }
public static void Main() { App.SplashScreenCreatedEvent = new ManualResetEvent(false); // Show the splash screen on a background thread, with a separate WPF dispatcher running on it. // This way, that splash screen can be even animated, since it runs on a separate GUI thread. Thread splashScreenThread = new Thread(SplashScreenThreadStartingPoint); splashScreenThread.SetApartmentState(ApartmentState.STA); splashScreenThread.IsBackground = true; splashScreenThread.Start(); // The app must not try to close the splash screen until it is fully created by the background thread App.SplashScreenCreatedEvent.WaitOne(); log4net.Config.XmlConfigurator.Configure(); // Classic way of starting up our application: TimeMerge.App app = new TimeMerge.App(); app.ShutdownMode = ShutdownMode.OnMainWindowClose; app.DispatcherUnhandledException += app_DispatcherUnhandledException; app.InitializeComponent(); app.Run(); }