I wanted to open a new WPF window
from my MainWindow's ViewModel
with a 2 second delay by doing the following:
await Task.Delay(2000).ContinueWith(_ =>
{
Restart wndRestart = new Restart();
wndRestart.Show();
}
);
Sadly, I am constantly getting: System.InvalidOperationException: 'The calling thread must be STA, because many UI components require this.'
I actually looked up this, but I was unable to use [STAThread]
even after refactoring a method.