Ejemplo n.º 1
0
        public void run_application()
        {
            var waitForApplicationStart = new ManualResetEvent(false);

            _thread = new Thread(() =>
            {
                _app          = new System.Windows.Application();
                _app.Startup += (s, e) =>
                {
                    waitForApplicationStart.Set();
                    _app.MainWindow = new Window();
                    _app.MainWindow.ShowDialog();
                };
                _app.Run();
            });
            _thread.IsBackground = true;
            _thread.SetApartmentState(ApartmentState.STA);
            _thread.Name = "Application under testing";
            _thread.Start();
            waitForApplicationStart.WaitOne();

            _dispatcher = Dispatcher.FromThread(_thread);
            _dispatcher.Invoke(new ThreadStart(() => _window = _app.MainWindow as TestApp.Window));

            _process          = Process.GetCurrentProcess();
            _application      = new Application(_process);
            _windowAutomation = _application.FindWindow("MainWindow");
            //  Thread.Sleep(TimeSpan.FromSeconds(20));
        }
Ejemplo n.º 2
0
        public void run_application()
        {
            var waitForApplicationStart = new ManualResetEvent(false);

            _thread = new Thread(() =>
                                     {
                                         _app = new System.Windows.Application();
                                         _app.Startup += (s, e) =>
                                                             {
                                                                 waitForApplicationStart.Set();
                                                                 _app.MainWindow = new Window();
                                                                 _app.MainWindow.ShowDialog();
                                                             };
                                         _app.Run();
                                     });
            _thread.IsBackground = true;
            _thread.SetApartmentState(ApartmentState.STA);
            _thread.Name = "Application under testing";
            _thread.Start();
            waitForApplicationStart.WaitOne();

            _dispatcher = Dispatcher.FromThread(_thread);
            _dispatcher.Invoke(new ThreadStart(() => _window = _app.MainWindow as TestApp.Window));

            _process = Process.GetCurrentProcess();
            _application = new Application(_process);
            _windowAutomation = _application.FindWindow("MainWindow");
              //  Thread.Sleep(TimeSpan.FromSeconds(20));
        }