While saving some code, I found that we have endless hangs in the background worker . The worker requires access to the script file. The original code was written to pop up a file dialog box if a script file was not defined to allow the user to select it. It looks something like this:
private void bgworker_DoWork(object sender, DoWorkEventArgs e)
{
... snip ...
if (String.IsNullOrWhitespace(scriptFile))
{
scriptFile = PromptForScript();
}
... snip ...
}
private string PrompForScript()
{
string script = "";
OpenFileDialog openDialog = new OpenFileDialog();
if (openDialog.ShowDialog() == DialogResult.OK)
{
script = openDialog.FileName;
}
return script;
}
I read a little about MethodInvoker, but almost all calling methods require you to call them from a control. The background worker in question works from a separate class that does not expandControl . Am I using a form that calls a class using bgworker? Or is there another way to interrupt a stream for user input?