473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Marshal a tree structure across threads?

Ouch. I've got a nasty problem here.

I need to load a tree structure into a treeview from a database. I've just
tested it with 10,000 items and its dog slow (one of the main reasons is
because I am manually "filtering" the items with my own filtering
structures). What I want to do is run a thread which constructs the
TreeView (and nodes) so that the rest of the GUI remains responsive. Then,
when the thread completes, I want to then marshal this TreeView structure
into the main process so that I can use it (at least make
mainprocess.TreeView.Nodes = threadprocess.TreeView.Nodes).

Any ideas?


Nov 20 '05 #1
1 1116
"Robin Tucker" <id*************************@reallyidont.com> schrieb
Ouch. I've got a nasty problem here.

I need to load a tree structure into a treeview from a database.
I've just tested it with 10,000 items and its dog slow (one of the
main reasons is because I am manually "filtering" the items with my
own filtering structures). What I want to do is run a thread which
constructs the TreeView (and nodes) so that the rest of the GUI
remains responsive. Then, when the thread completes, I want to then
marshal this TreeView structure into the main process so that I can
use it (at least make mainprocess.TreeView.Nodes =
threadprocess.TreeView.Nodes).

(why to the Interop group?)
Class CreateNodesThread
Private m_Thread As Threading.Thread

Public Event Done(ByVal Nodes As TreeNode())

Sub Start()
m_Thread = New Threading.Thread(AddressOf ThreadProc)
m_Thread.Start()
End Sub

Private Sub ThreadProc()
Dim Nodes(1) As TreeNode
Nodes(0) = New TreeNode("1")
Nodes(1) = New TreeNode("2")
RaiseEvent Done(Nodes)
End Sub
End Class

In a Form:
Private m_CreateNodesThread As CreateNodesThread

Private Sub OnCreateNodesThreadDone(ByVal Nodes As TreeNode())
If TreeView1.InvokeRequired Then
TreeView1.BeginInvoke( _
New CreateNodesThread.DoneEventHandler( _
AddressOf OnCreateNodesThreadDone _
), _
New Object() {Nodes} _
)
Else
RemoveHandler m_CreateNodesThread.Done, _
AddressOf OnCreateNodesThreadDone

m_CreateNodesThread = Nothing
TreeView1.Nodes.AddRange(Nodes)
End If
End Sub
Start the job:
m_CreateNodesThread = New CreateNodesThread
AddHandler m_CreateNodesThread.Done, AddressOf OnCreateNodesThreadDone
m_CreateNodesThread.Start()

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ivan | last post by:
Hi All, I have a problem with marshaling complex structures (containing numbers, strings, arrays of another structures) to native C function in dll. I have already posted same question to...
12
by: pillepop2003 | last post by:
Hey! Can anyone give me a hint, how this problem is best implemented: I have a table of users (see below), where every user has one "superior user" (= parent node), this should be a fully...
15
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked...
0
by: Ivan | last post by:
Hi All, I have a problem with marshaling complex structures (containing numbers, strings, arrays of another structures) to native C function in dll. I have already posted same question to...
4
by: Ken | last post by:
I have a binary tree in VB NET and insertions seem to be slow. The program receives data from one source and inserts it into the tree. The program receives data from another source and...
4
by: Michael McGarry | last post by:
Hi, I am using the marshal module in python to save a data structure to a file. It does not appear to be portable. The data is saved on a Linux machine. Loading that same data on a Mac gives me...
21
by: Mike | last post by:
Hi, The example below shows that result of a marshaled data structure is nothing but a string >>> data = {2:'two', 3:'three'} >>> import marshal >>> bytes = marshal.dumps(data) >>>...
4
by: cleanrabbit | last post by:
Hello! I hate having to do this, because im almost certain there is someone in the world that has come across this problem and i just havent found their solution yet, so i do appologise if this...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.