… class Program1 { … private void ShowWindow() { _MainWindow = new MainWindow(); Application app = new Application(); app.Run(_MainWindow); app.Shutdown(); } public void StartWindow (){ appthread = new Thread(ShowWindow); appthread.Name = "wth"; appthread.SetApartmentState(ApartmentState.STA); appthread.IsBackground = true; appthread.Start(); } … } …