TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
monkeyboy123456789
NA
3
0
Threading, Events and UI Update
Oct 8 2004 8:43 AM
I start a lengthy process using a worker thread from my main form. Form frmMain Fields... Private WithEvents run as New CRun Private tRun as Threading.Thread() Here's how I kick off the thread... tRun = New Threading.Thread(AddressOf run.Run) tRun.Start() I use events in the Run method of the run object to communicate it's progress back to the UI. In each event handler on frmMain I update a label's text property so that the user knows how the processing is progressing. The program experiences no problems whatsoever when doing this. When the processing completes the Run method raises a RunComplete() event. I try to update a treeview control in the event handler but I get the following error message: The action being performed on this control is being called from the wrong thread. You must marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action. I could understand getting this error message if I was trying to update the treeview directly from the worker thread but I am updating the treeview from an event handler in the main form. Also the fact that the label control is being updated with no problems in the other event handlers seems odd. Who don't I get the same error message when I do that? Can anybody give me some insight as to what's going on? Thanks in advance.
Reply
Answers (
1
)
Message Box
Call a class