J
jjkboswell
If I have a form with a button and add a button_Click event handler,
and within that handler I update the form's GUI, do I need to marshal
onto the main thread?
i.e. Do I need to do this:
private void button1_Click(object sender, System.EventArgs e)
{
if (InvokeRequired)
{
Invoke(new EventHandler(button1_Click),
new object[] {sender, e});
}
else
{
button1.Text = "stuff";
}
}
I think what I'm asking is:
Can form event handlers be on a different thread from the main thread?
Any clarifcation on this appreciated!
Boz
and within that handler I update the form's GUI, do I need to marshal
onto the main thread?
i.e. Do I need to do this:
private void button1_Click(object sender, System.EventArgs e)
{
if (InvokeRequired)
{
Invoke(new EventHandler(button1_Click),
new object[] {sender, e});
}
else
{
button1.Text = "stuff";
}
}
I think what I'm asking is:
Can form event handlers be on a different thread from the main thread?
Any clarifcation on this appreciated!
Boz