This is simple, but it would take long time to explain all the detail, so here is an example for you:
Suppose you have some code like
void MyFunction(A a, B b, C c) {}
A aValue =
B bValue =
C cValue =
MyFunction(aValue, bValue, cValue);
How to delegate it to the UI thread with
this.Dispatcher.BeginInvoke
? You should pass a delegate instance of appropriate delegate type, followed by the set of parameters to be passed to the delegate instance. This is how:
this.Dispatcher.BeginInvoke(new System.Action<A, B, C>((a, b, c)=>{
}), aValue, bValue, cValue);
Method
BeginInvoke
will pass
aValue
,
bValue
and
cValue
— actual parameters — to the invocation of the delegate instance as the parameters
a
,
b
and
c
. Note, that in this form of delegate description, the compiler uses
type inference. I suggest you learn how it works and analyze the role of all types (
Action
, delegate type, delegate instance object type and so on) by yourself.
—SA