B
Bry
I have a simple Windows form class called Console. The form comprises
solely of a RichTextBox.
I recently added multi threading to my application and as a result I've
started having problems when I try to call the .Show() method for the
form, so I implemented a delegate as follows:
delegate void cb_ShowConsole();
// - - 8< - - irrelevant code snipped - - 8< - -
private void ts_ShowConsole()
{
// Thread safe call to the Console.Show() method
if (InvokeRequired)
{
cb_ShowConsole d = new cb_ShowConsole(ts_ShowConsole);
this.Invoke(d, new Object[] { });
}
else
{
myConsole.Show(); // ***** THIS LINE CAUSES THE
EXCEPTION ****
}
}
however I receive a "InvalidOperationExcpetion" on the highlighted line
above.
I have used this method in other places throughout my code with
success, however this section of code does not work.
Can anyone see what I'm doing wrong?
Thanks,
Bry.
solely of a RichTextBox.
I recently added multi threading to my application and as a result I've
started having problems when I try to call the .Show() method for the
form, so I implemented a delegate as follows:
delegate void cb_ShowConsole();
// - - 8< - - irrelevant code snipped - - 8< - -
private void ts_ShowConsole()
{
// Thread safe call to the Console.Show() method
if (InvokeRequired)
{
cb_ShowConsole d = new cb_ShowConsole(ts_ShowConsole);
this.Invoke(d, new Object[] { });
}
else
{
myConsole.Show(); // ***** THIS LINE CAUSES THE
EXCEPTION ****
}
}
however I receive a "InvalidOperationExcpetion" on the highlighted line
above.
I have used this method in other places throughout my code with
success, however this section of code does not work.
Can anyone see what I'm doing wrong?
Thanks,
Bry.