Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cross-thread operation not valid - Treeview

Posted on 2011-03-17
3
Medium Priority
?
837 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 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