воскресенье, 20 мая 2018 г.

Launch Wpf Windows from Console App

https://stackoverflow.com/questions/43388308/show-wpf-window-from-console-app

https://stackoverflow.com/questions/2329978/the-calling-thread-must-be-sta-because-many-ui-components-require-this

https://stackoverflow.com/questions/8047610/re-open-wpf-window-from-a-console-application


Work well
WinThread1 = new Thread(() =>
            {
                EventLogWindow2 = new EventLogWindow2();
                EventLogWindow2.Init(EventLog);
                EventLogWindow2?.Show();

                EventLogWindow3 = new EventLogWindow3();
                EventLogWindow3.Init(EventLog);
                EventLogWindow3?.Show();

                Dispatcher.Run();
            });
            WinThread1.SetApartmentState(ApartmentState.STA);
            WinThread1.Start();

Does not work
Application.Current.Dispatcher.Invoke(() =>
            {
                EventLogWindow2 = new EventLogWindow2();
                EventLogWindow2.Init(EventLog);
                EventLogWindow2?.Show();

                EventLogWindow3 = new EventLogWindow3();
                EventLogWindow3.Init(EventLog);
                EventLogWindow3?.Show();
            });

Комментариев нет:

Отправить комментарий