Trying to use anonymous methods to invoke code on a control

G

Guest

With the full .net compact framework, if you want to update a control from a
different thread from which it was created, and you want to use an anonymous
method to invoke your delegate to do the code, you do something like this:

this.Invoke((MethodInvoker)delegate()
{
this.Text = "x";
});

But with the .net compact framework it looks like MethodInvoker is not
supported. So does anyone know how I would do the equivalent when using the
compact framework? I don't want to have to explicitly create the delegate
function. I want to use an anonymous method to do it.

Thanks,

Brad
 
T

Tomer Gabel

Hello Brad,

Just declare a private delegate for that purpose. You could even cast to
a completely arbitrary delegate type (EventHandler for instance) and it'll
usually work, but is not as elegant.

I usually just redeclare a "private static delegate void MethodInvoker();"
and use that.

Regards,
Tomer Gabel (http://www.tomergabel.com)
Monfort Software Engineering Ltd. (http://www.monfort.co.il)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top