Exemple #1
0
        public void Start()
        {
            Dispatcher.CurrentDispatcher.BeginInvoke(
                (Action)(() =>
            {
                Shell.Show();
                Shell.Activate();
                Shell.Topmost = true;    // important
                Shell.Topmost = false;   // important
                Shell.Focus();           // important
                EventAggregator.GetEvent <CloseSplashEvent>().Publish(new CloseSplashEvent());
            }));

            WaitForCreation = new AutoResetEvent(false);

            ThreadStart showSplash =
                () =>
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(
                    (Action)(() =>
                {
                    var splash = new Views.SplashView();
                    EventAggregator.GetEvent <CloseSplashEvent>().Subscribe(e => splash.Dispatcher.BeginInvoke((Action)splash.Close), ThreadOption.PublisherThread, true);

                    splash.Show();

                    WaitForCreation.Set();
                }));

                Dispatcher.Run();
            };

            var thread = new Thread(showSplash)
            {
                Name = "Splash Thread", IsBackground = true
            };

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();

            WaitForCreation.WaitOne();
        }