Control.Invoke vs. timers for syncing UI with background tasks

  • Thread starter Thread starter Dan Foody
  • Start date Start date
D

Dan Foody

I had a background task collecting data from a server which wanted to
update lots of parts of the UI with new information (potentially while
the user is interacting with it).

At first I was using Control.Invoke to get work done on the UI thread
-- but this was resulting in all sorts of random
System.ExecutionEngineException crashes.

When I switched the UI to periodically read the data from a queue (in
a timer event), these crashes went away.

Does anyone know how/why Control.Invoke would have these problems
versus doing the exact same work in a timer event? And, how would I
avoid them (since I'd prefer to use this async approach rather than a
timer-based polling approach).

Thanks
 
Hi,

Thanks for your post. Control.Invoke makes synchronous method calls, I
suggest you to use Contro.BeginInvoke which makes asynchronous method calls
and then check whether or not the problem still exists.

In addition, could you please tell me the detailed exception message?

I look forward to your response.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top