Ejemplo n.º 1
0
        private void StartGinger()
        {
            // 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();
                WorkSpace.Init(new WorkSpaceEventHandler());
                WorkSpace.Instance.RunningFromUnitTest = true;
                WorkSpace.Instance.InitWorkspace(new GingerWorkSpaceReporter(), new DotNetFrameworkHelper());


                app.HideConsoleWindow();
                app.StartGingerUI();

                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 Main window to be ready
            int i = 0;

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


            // Here Ginger is live and visible
            isReady = true;
        }