In my application WPFthat uses frames Caliburn.Microand MahApps.Metro, I open instances OpenFileDialogfrom the namespace System.Windows.Forms. After opening and closing this dialog, the rest of my application freezes for about 3 to 4 seconds. This is also true when using a namespace Microsoft.Win32.
I did some research on my own and came up with several posts complaining about the same problem, and the solutions they found were doubled:
- Quick fix: set the property
ShowHelptotrue - Correct fix: make sure it works in mode
Single Threaded Apartment.
The fix ShowHelpworks for me using a non-vista style dialog, but from the point of view UXin Windows Vista and newer it doesn’t look like that. Another thing for me then would be to provide it in mode STA.
WPFuses by default STA, but I tried to write my own main method and explicitly specify [STA], but no luck. I added the snippet below to my code, but the output State: STA, indicating that there should be no problems.
Console.WriteLine("State: {0}", System.Threading.Thread.CurrentThread.GetApartmentState());
var dialog = new OpenFileDialog
I also tried running OpenFileDialogin a new thread STA, and although it launches and does not hang my application, it is also not modal. I also tried joining a new thread, but it still freezes after closing.
Question
OpenFileDialog, , FileDialogs, ?
ShowHelp STA: