I created a new window in a separate dispatcher
Dispatcher dispatcher = null;
var newWindowThread = new Thread(() =>
{
MainWindow window = new MainWindow();
window.ShowDialog();
});
newWindowThread.SetApartmentState(ApartmentState.STA);
newWindowThread.IsBackground = true;
newWindowThread.Start();
while (dispatcher == null)
{
Thread.Sleep(10);
dispatcher = Dispatcher.FromThread(newWindowThread);
}
and then using this dispatcher I can Invoke some actions, but in this case this window is modal, I don't like it and I need a separate window which is not modal.
When I use Show() instead of ShowDialog() then execution goes to the end and my dispatcher will not work.
How can I put it in a infinite loop?
But tread needs to be active and response to Invoke().