根据MSDN,ThreadStateException的发生主要是因为新的Thread在主线程中创建了OpenFileDialog的工具;
private void button_FileExercise_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory = "C:\\";
fileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
}
}
ThreadStateException发生在“if”,因此,我如何解决类似的程序,THX!