I have WinForms UI code in static dll module for my app. Main form has a dialog form, which calls the openfiledialog, when the user needs to change the file path. If I create main winform object in the main thread, than in the new thread call Application::run() all works fine. If I move a main winform object creation in the same thread which will call Application::run(), this works fine for Win XP, but there is hung up for Win7 and Win8.
答案 0 :(得分:1)
FileDialog.AutoUpgradeEnabled默认为true,这意味着在Vista +上运行时,文件对话框将使用IFileDialog接口。 Vista文件对话框基于COM。它需要一个STA线程(ApartmentState = ApartmentState.STA)以及一个消息泵(如Application :: Run)来避免挂起。