Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys!
Thx for reding!

My Situation:
i use VB.NET 3.5, VS2008
i have got an tree of data. i got the data via an app api call.
about: 300MB, 1100 Nodes. max tree deep of 6

my single thread func:
Private Function IterateThruTree(ByVal AktComponet As Component, ByVal AktDeep As Integer) As sBillOfMatiereal
  ...
  For Each lComponet As Component In AktComponet.GetChildren()
                If _bCancle Then Exit Function
                lBoM = IterateThruTree(lComponet, AktDeep + 1)
   ...
   next
...
end funtion


i wonne do this in threads. a friend of mine told me to make a class and inherit from thread. but it think this produce a lot of overhead. i think an threadpool would do it better.
any good ideas?

so far, happy new year!
Posted
Updated 31-Dec-09 5:38am
v2

Well, you could store a count of threads at the class level. Whenever a new thread is created, add to the count. When the thread is complete, remove from the count. When the maximum count is reached, wait for it to be reduced before starting a new thread. You would likely do this check to make new threads inside the for loop you have above. So, if the threads are at max, then just recursively call IterateThruTree. But if the threads are less than max, then call IterateThruTree as a new thread. There are various things you'll want to keep in mind, such as thread pooling, resource locking, and returning values, but I'll leave the details to you.
 
Share this answer
 
aspdotnetdev wrote:
So, if the threads are at max, then just recursively call IterateThruTree. But if the threads are less than max, then call IterateThruTree as a new thread.


Thats an realy good idea, thx.
 
Share this answer
 
v2
wrote:
i wonne do this in threads.


I will not recommend to use multi threading just to iterate over the tree. It will make the code complex and it is very tough to maintain the order of iteration. Do the iteration on single thread and spawn new threads for processing.
 
Share this answer
 
wrote:

I will not recommend to use multi threading just to iterate over the tree. It will make the code complex and it is very tough to maintain the order of iteration. Do the iteration on single thread and spawn new threads for processing.


its the iteration what costs the cpu time, not the processing!
i do not process any data.

i dont ask qusetion if google or a good book would give me an answer. i know its freaky. its the same with girls. they are quite freaky too (+complex and very hard to maintain) but its worth :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900