开发者

what is invoking?

开发者 https://www.devze.com 2023-03-23 21:45 出处:网络
What is method invoke, control.invoke? What is invoking in general in programming examples : MethodInvoker getValues = new MethodInvoker(delegate()

What is method invoke, control.invoke?

What is invoking in general in programming

examples :

MethodInvoker getValues = new MethodInvoker(delegate()
{
    checkbox1Checked = checkbox1.Checked;
    textBox6Text = textBox6.Text;
    textBox7Text = textBox7.Text;
    textBox3Text = textBox3.Text;
    textBox1Text = tex开发者_如何学GotBox1.Text;
    textBox4Text = textBox4.Text;
    richTextBox1Text = richTextBox1.Text;
    textBox5Text = textBox5.Text;
});

if (this.InvokeRequired)
{
    this.Invoke(getValues);
}
else
{
    getValues();
}

And I also wanna know what does MethodInvoker and InvokeRequired mean?


“Invoking” refers to calling a method.

In winforms Control.Invoke is used to call a method on the UI thread — without it you can cause an exception by updating the UI from another thread.

And so if InvokeRequires returns true it means that you are not running in the UI thread and should use Control.Invoke to run the call in the right thread.

0

精彩评论

暂无评论...
验证码 换一张
取 消