添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

为什么Winform中新开 Thread 调用 OpenFileDialog 时要设置 STA 模式

引子,一位同学在使用线程时,业务需要调用打开文件窗口,遇到的有意思的问题!

先看正确案例代码

Thread myThead = new Thread(() => {
     OpenFileDialog myOpenFileDialog = new OpenFileDialog();
     if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
         // TODO ...