Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / May 2006

Tip: Looking for answers? Try searching our database.

selectednode in Treeview lost when accessed by spawned Thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dean Hinson - 30 May 2006 21:03 GMT
Hello,

I am trying to spawn a sunroutine in a worker thread for populating a
trreeview.  I set the selectednode and then start the thread. However, the
thread errors because the selectednode was found to equal "Nothing".

Is there some kind of trick to get the threaded subroutine to see the
selectednode to process?

Thank you inadvance for any assistance.

Dean.
Brian Gideon - 31 May 2006 14:39 GMT
Dean,

You can't access a form or control from a thread other than the main UI
thread.  That doesn't mean you can't take advantage of threads though.
What I would do is use my worker thread to retrieve the list of items
from the database or whatever and place them in some type of collection
and then call Control.BeginInvoke at the end of the worker thread to
marshal the execution of a delegate onto the UI thread.  That delegate
would build the treeview from the collection you just populated.

The following is an excellent introduction to using threads in Windows
forms.

<http://www.yoda.arachsys.com/csharp/threads/winforms.shtml>

Brian

> Hello,
>
[quoted text clipped - 8 lines]
>
> Dean.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.