A problem with Invoke(Delegate method, Object[] args) parameter count
I got an exeption like
System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
But System.Windows.Forms.Control contains only Invoke(Delegate method, params Object[] args) method but not Invoke(Delegate method, Object[] args). And I use it like
Invoke(new SetXDelegate(SetX), value1, value2)
Is it the reason of my problem and I mus开发者_StackOverflow社区t use
Invoke(new SetXDelegate(SetX), new object[] {value1, value2})?
UPDATE
Please recommend if it better to use something like
Invoke((MethodInvoker)delegate { SetX(value1, value2); })
to avoid this kind of problems.
Thanks.
Yes you should. It takes an array of objects
Edit
The problem could be that SetXDelegate doesn't take two parameters.
Actually I think it's complaining that you're passing the wrong number of parameters for SetX to use. What parameters does SetX take?
精彩评论