I'm using this code to run ProgressBar in separate thread.
ProgresBarForm viewer = new ProgressBarForm("Wait");
Thread viewerThread = new Thread(delegate()
{
viewer = new ProgressBarForm("Wait");
viewer.Show();
System.Windows.Threading.Dispatcher.Run();
});
viewerThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception
viewerThread.Start();
Then i'm doing some long operation and when i finish i'm invoking this code:
viewer.BeginInvoke(new Action(() => window.Close()));
and it works really well but when I close my window debugger is not stopping. In VS 2012 I click "Break All" button and it occurs that program is hanging on line
System.Windows.Threading.Dispatcher.Run();
How can I close this dispatcher to exit from my program?
Thanks in advance for all responses.