How to use the Dispatcher.BeginInvoke in MF 4.1?

Hello Guys,

I am new to the Dispatcher in MF 4.1.

in 3.0

i needed to create a delegate for example :

public delegate void mycallbackobject(Object p)

so i could use the Dispatcher in private static GPIOButtonInputProvider myGPIO to update my UI Element.

myGPIO.Dispatcher.BeginInvoke(new mycallbackobject(MethodOfDispatcher), false)

but the same code won’t work on MF4.1.

when I look at it, it seems there are some changes made since MF 4.0.

dispatcher in 3.0

public DispatcherOperation BeginInvoke(Delegate method, params object[] args);

dispatcher in 4.1

public DispatcherOperation BeginInvoke(DispatcherOperationCallback method, object args)

how do I change my code to adapt 4.1? :-[

Change signature of MethodOfDispatcher to

object MethodOfDispatcher(object arg)

Then you can use it like this:

myGPIO.Dispatcher.BeginInvoke(MethodOfDispatcher, false)

The only difference is that in previous version you could create your own delegate. Now you are givent a predefined DispatcherOperationCallback delegate.

It will work like this way too…


myGPIO.Dispatcher.BeginInvoke(delegate(object args)
            {
                //your code
                return null;
            }, null);