Exemple #1
0
        private void StartGinger()
        {
            Ginger.SplashWindow splash = null;
            // We start Ginger on STA thread
            mGingerThread = new Thread(() =>
            {
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));

                // we need sample class - Dummy
                Ginger.GeneralLib.Dummy d = new Ginger.GeneralLib.Dummy();
                Assembly asm1             = d.GetType().Assembly;
                // Set the app resources to Ginger so image an other will be locally to Ginger
                Application.ResourceAssembly = asm1;

                app = new Ginger.App();
                Ginger.App.RunningFromUnitTest = true;
                splash = new Ginger.SplashWindow();
                splash.Show();
                //Ginger. WorkSpace.UserProfile.AutoLoadLastSolution = false;

                while (!app.IsReady && splash.IsVisible)
                {
                    Thread.Sleep(100);
                }

                GingerPOMBase.Dispatcher = app.GetMainWindowDispatcher();

                //Ginger.App.MainWindow.Closed += (sender1, e1) =>
                //    Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                MainWindowPOM = new MainWindowPOM(Ginger.App.MainWindow);

                // Makes the thread support message pumping
                System.Windows.Threading.Dispatcher.Run();
            });


            //// Configure the thread
            mGingerThread.SetApartmentState(ApartmentState.STA);
            mGingerThread.IsBackground = true;
            mGingerThread.Start();

            //max 60 seconds for Mainwindow to be ready
            int i = 0;

            while (MainWindowPOM == null && i < 600)
            {
                Thread.Sleep(100);
                i++;
            }


            while (splash.IsVisible)
            {
                Thread.Sleep(100);
            }
            // Here Ginger is live and visible
            isReady = true;
        }
        //public static Dispatcher mDispatcher;
        public void StartGinger()
        {
            mutex.WaitOne();

            if (app != null)
            {
                return;
            }

            Ginger.SplashWindow splash = null;
            // We start Ginger on STA thread
            var t = new Thread(() =>
            {
                // we need sample class - Dummy
                Ginger.GeneralLib.Dummy d = new Ginger.GeneralLib.Dummy();
                Assembly asm1             = d.GetType().Assembly;
                // Set the app resources to Ginger so image an other will be locally to Ginger
                Application.ResourceAssembly = asm1;

                app    = new Ginger.App();
                splash = new Ginger.SplashWindow();
                splash.Show();
                //Ginger.App.UserProfile.AutoLoadLastSolution = false;

                while (!app.IsReady && splash.IsVisible)
                {
                    Thread.Sleep(100);
                }

                GingerPOMBase.mDispatcher = app.GetMainWindowDispatcher();
                MainWindowPOM             = new MainWindowPOM(Ginger.App.MainWindow);

                // Makes the thread support message pumping
                System.Windows.Threading.Dispatcher.Run();
            });


            //// Configure the thread
            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            //max 60 seconds for Mainwindow to be ready
            int i = 0;

            while (MainWindowPOM == null && i < 600)
            {
                Thread.Sleep(100);
                i++;
            }


            while (splash.IsVisible)
            {
                Thread.Sleep(100);
            }
            // Here Ginger WPF is live and visible
        }