// JP opened flex table

Click to See Complete Forum and Search --> : HELP - Load a Treeview control with BackGroundWorker process


CD-Softy
April 28th, 2007, 04:07 PM
Hi,
I need help from a multi-threading VB.NET guru!
I have a simple windows form with a treeview control on it. I want to load the form and show the treeview control (this is easily done). But now, I would like to start a background process after the form is displayed to load the treeview with information from a database in the background while displaying a progress bar in the treeview control (AJAX style). When the bg worker has loaded all the data to the treeview, the progress bar disappears and the treeview is shown to the user.

The nodes on the tree are multi-level so there is some recursion that is needed too.

I have never used multi-threading before, so this is all new to me. I have looked at the MSDN examples for the bg worker component but it's beyond me.

My preference is VB.NET, but I can translate C# code ...

Please help.

TheCPUWizard
April 28th, 2007, 04:15 PM
You need to only update your UI from the thread that created the controls. PERIOD.

What your background process can do is gather a "chunk" of information, put it in a container that is thread safe, and alert the UI thread to take the contents of the container and poplate the control....

CD-Softy
April 29th, 2007, 02:07 AM
OK, that's makes sense...

If I understood, I presume the bg worker would create a collection of nodes and send it to the UI via the e.Result arg, and have the UI thread draw it onto the tree right? Is this what you meant by "container"?

Thanx for the reply

//JP added flex table