I am looking for information on using a treeview in safethread manner. Does any one have experance with this or know of some online links to research.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the MSDN documentation on System.Windows.Forms.TreeView:
Fortunately for you, there is a mechanism in Windows Forms to handle controls from multiple threads in a thread safe way:
Now you can invoke this function from any thread:
This will guarantee that the code that manipulates your tree will be executed in the thread that created the TreeView, hence it will be thread-safe. If you don’t want to inherit from TreeView, you can just use
treeInstance.InvokeRequiredandtreeInstance.Invoke().