?
Solved

Cross-thread operation not valid - Treeview

Posted on 2011-03-17
3
Medium Priority
?
830 Views
Last Modified: 2012-06-27
Hi,

I've used 'the wizard' to convert a VB app created VS2003 to .Net 3.5 using Visual Studio 2010.  On running it everything seems to work (at least the core app, I've stripped out a few old bits and pieces for now) but I am getting an error with the Treeview control (called ProcessTree) - I haven't looked too far into this but I'd see if anyone could give me an easy explanation first ?

Error description -

"
Cross-thread operation not valid:
Control 'ProcessTree' accessed from a thread other than the thread it was created on.

"
Thanks.
0
Comment
Question by:gringogordo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 400 total points
ID: 35158787
UI controls can only be manipulated from the UI Thread.  In your case, it seems that a background worker thread is doing something with ProcessTree, which is causing the exception.  Another scenario for this error occurs when the background thread creates the control and the UI Thread tries to use it.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 600 total points
ID: 35159100
Can you show the code that is causing the error?

VS2003 actually ignored this type of coding error.

You several options:
(1) Turn off this type of checking. *not recommended*
(2) Use manual Delegates and Invoke() to fix the problem.
(3) Use newer threading constructs such as the BackgroundWorker().
(4) Use a SynchronizationContext() to do the udpates.
0
 

Author Closing Comment

by:gringogordo
ID: 35164856
Thanks very much.  I hope the points allocaton is okay.  Points for 1st and points for advice!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question