PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Trying to use anonymous methods to invoke code on a control
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Trying to use anonymous methods to invoke code on a control
![]() |
Trying to use anonymous methods to invoke code on a control |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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) > 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 > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

