Been trying to implementing ThreadPool over a large and variable amount of data like the following:
This of course will bomb out if we have more than 64 items/threads being placed on the ThreadPool.Code:public sub ProcessWorkItem(byval state as object) Dim originalState as CustomStateInfo = CType(state, CustomStateInfo) 'Do stuff originalState.ManualResetEventInstance.Set() end sub ' ' public sub DoWork() Dim myData as List(Of Something) = someSource.GetData() 'this can be 100, 4000 or more objects in the collection for each currentItem as Something in myData ThreadPool.QueueUserWorkItem(......) 'somewhere here we do a WaitHandle.WaitAll(.....) next end sub
So, how would one process say x amount of items until there are no more items left to process? What is a better way of doing this?





any chance of a regain? 
Reply With Quote