C# How to invoke with more than one parameter
25,744
(edit - I think I misunderstood the original question)
Simply make it a method instead of a property:
public void DoSomething(string foo, int bar)
{
if (this.InvokeRequired) {
this.Invoke((MethodInvoker)delegate {
DoSomething(foo,bar);
});
return;
}
// do something with foo and bar
this.Text = foo;
Console.WriteLine(bar);
}
Comments
-
P. Duw almost 2 years
I use the code below to access the properties on my form,but today I'd like to write stuff to a ListView,which requires more parameters.
public string TextValue { set { if (this.Memo.InvokeRequired) { this.Invoke((MethodInvoker)delegate { this.Memo.Text += value + "\n"; }); } else { this.Memo.Text += value + "\n"; } } }
How to add more than one parameter and how to use them(value,value)?