M
MikeE
Hi all,
What's the best way to queue up and wait for number of threads to complete.
This problem was trivial in VC++ 6 but I'm finding it rather hard to solve
in VB.NET. My calculations run about 2 mins each (on a 2.8 Ghz Xeon and the
server range from 2 to 8 processors) (give or take about 15 secs). I have 8
sets of calculations to do (in another app I have 121) all the same calc
just different data. But the rest of the processing cannot continue until
ALL of the calculations are done.
so here's the algorithm I want to use (written from the C++ implentation
standpoint) {for ease of reading i have left out any/all discussion about
the queue ops used to schedule the runs which can change to what ever is
appropriate}
------------------------------------------------------------------
get user pref on number of concurrent threads...
for loop (to number of concurrent threads)
start a thread (with data)
add to wait list
while true
WaitForMultipleObjects(...threads...)
if more threads to process
launch thread with data
add to wait list
else if all threads finished
break
------------------------------------------------------------------
The problem I'm having is finding the .NET equivalent to
WaitForMultipleObjects. The threads might not complete in order or might
complete at the same time. I was toying with the idea of a delegate that
would basically have the functionality of the while loop, but seemed like
spaghetti coding to me.
Any ideas or examples you can think of would be greatly appreciated.
Thanks in advance,
Mike
What's the best way to queue up and wait for number of threads to complete.
This problem was trivial in VC++ 6 but I'm finding it rather hard to solve
in VB.NET. My calculations run about 2 mins each (on a 2.8 Ghz Xeon and the
server range from 2 to 8 processors) (give or take about 15 secs). I have 8
sets of calculations to do (in another app I have 121) all the same calc
just different data. But the rest of the processing cannot continue until
ALL of the calculations are done.
so here's the algorithm I want to use (written from the C++ implentation
standpoint) {for ease of reading i have left out any/all discussion about
the queue ops used to schedule the runs which can change to what ever is
appropriate}
------------------------------------------------------------------
get user pref on number of concurrent threads...
for loop (to number of concurrent threads)
start a thread (with data)
add to wait list
while true
WaitForMultipleObjects(...threads...)
if more threads to process
launch thread with data
add to wait list
else if all threads finished
break
------------------------------------------------------------------
The problem I'm having is finding the .NET equivalent to
WaitForMultipleObjects. The threads might not complete in order or might
complete at the same time. I was toying with the idea of a delegate that
would basically have the functionality of the while loop, but seemed like
spaghetti coding to me.
Any ideas or examples you can think of would be greatly appreciated.
Thanks in advance,
Mike