Trying to use anonymous methods to invoke code on a control

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 
Back
Top