Multithreading and Control.Invoke

  • Thread starter Thread starter Magne Ryholt
  • Start date Start date
M

Magne Ryholt

I have a multithreaded application on iPAQ 5550 with CF 1.0 SP2.
Using Invoke on a control (from another thread than the one which created
the control) to let UI thread do the visual updating.
The Invoke cannot take parameters (CF limitation).
This is working fine if I run the same exe file on my XP machine, but on the
iPAQ I get the exception "ArgumentException".

Is this a bug in CF or do I use it wrong way ? (note that it is working on
XP)

By the way, anyone knows how to Invoke properties on a control (to let the
UI thread set the property) ?
 
The method used as a target of Control.Invoke should have an EventHandler
signature:
void Method(object sender, EventArgs e)

Use it like this.
Form1.Invoke(new EventHandler(Method));

Full framework does not have this limitation, thus it works on the desktop
for you.
The parameters unfortunately have to be passed via a member variable
 
Thanks for your answer, it works.
Do you know if this is mentioned anywhere in the documentation (VS2003) ?
Anyway, this does not promote good and robust programming (particularily
that arguments must be passed as member variables
 
Back
Top