The overload of
Control.Invoke
has an overload with a
params
object array. The
params
parameter allows to pass a variable number of elements directly without the need to explicitly pack them into an array.
In params, you
cannot pass references. But keep in mind that if you pass
reference types, that they are by definition
reference paramater. I.e. whatever you modify
inside the invocation has an effect to the passed
reference type parameters.
Assuming you have instances of
reference types (not
value types) that you pass to the invocation, your call looks like this:
oDataGridView.Invoke(new MyHandler(MyFunc), x, y);
or even
oDataGridView.Invoke(MyFunc, x, y);
On the other hand, if you need to pass multiple
value types values as
references, you can pack them into some kind of container and pass the container (which is a
reference type) to the handler. If it's
homogenous types (all the same type), use any of the collections from
System.Collections.Generic
namespace. If it is
inhomogenous types (not all types are the same), use a
Tuple
or create your own specific argument class (e.g. like a class derived from
EventArg
like the ones used in
EventHandler
s).
Cheers
Andi