我有以下代码提示用户打开文件:
System::Windows::Forms::OpenFileDialog fd;
fd.Filter = "All files (*.*)|*.*";
fd.RestoreDirectory = true;
if (fd.ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
m_lblProgress->Text = "Opening file";
}
出于某种原因,在我单击对话框上的“确定”按钮后,GUI上的文本更新前需要约5秒钟,并且在发生这种情况之前它没有响应。
为什么会这样,我该如何避免呢?
编辑 - 情节变浓..
此延迟仅在从OpenFileDialog
事件启动System::Windows::Forms::ToolStripMenuItem::Click
时显示。
更改标签的文字而不是启动OpenFileDialog
并不会产生任何延迟,因此关闭OpenFileDialog
窗口会有什么特别之处?