View Single Post
  #1 (permalink)  
Old November 27th, 2009, 07:39 AM
dmn dmn is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 19 - Pooling Sample Code

Has anyone managed to get the Pooling sample to work? I have created my own application and downloaded the sample code for the book and both fail to run with the same problem.

Quote:
System.InvalidOperationException was unhandled

"Cross-thread operation not valid: Control 'txtStatus' accessed from a thread other than the thread it was created on."
The VS online help seems to be suggesting that we need to invoke the update to the control.

I've coded around the problem by sending the data to the output window.

To prove that I could get data back to the form I modified the WorkerEnd method to pass back some additional data that is stored in private member variables. I then have a timer that loops around and updates the UI every few seconds.
Reply With Quote