WPF Window stays open after debugging stops - WPFSurface process

Viewed 153

this might sound dumb, I am new in WPF and in my application I open an additional window using Task.Factory.StartNew because the function runs in separate thread. After the debugging stops, this window stays open but without any images, only the text/clicking/animations are shown, but through this I can open other windows, as if the software was still running, which actually does through a process called "WPFSurface.exe", I assume it's some sort of debugging or just a bug but I can't find any information on google or stackoverflow. Here's the code that I use to create the window:

Task.Factory.StartNew(() =>
                {
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        var controls = new ScreenControls(display);
                        controls.Show();
                    }));
                });

I also close the application using this code (Yes it's binded correctly to Closed event)

private void MainWindow1_Closed(object sender, EventArgs e)
        {
            Application.Current.Shutdown();
        }

Thank you for your time!

0 Answers
Related