View Single Post
  #2 (permalink)  
Old April 12th, 2007, 10:02 AM
planoie's Avatar
planoie planoie is offline
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It's not just bad practice, but it doesn't work. The runtime will throw an error when you try to update a control created by another thread.

It's been a while since I've done this, but it involves using the "BeginInvoke" method of the form class you want to update. Basically, BeginInvoke() takes a delegate to the method you want to invoke (this would be a method on the form that will update the controls). This causes the class on which BeginInvoke is called (the form) to perform the actual invocation of the method, thus crossing the thread boundary back to the one that owns the controls.

-Peter
Reply With Quote