Home:ALL Converter>Iterate Typed List in sections

Iterate Typed List in sections

Ask Time:2010-12-18T03:45:55         Author:Saif Khan

Json Formatter

I have the following list

Dim ordersToUpdate as New List(Of OrderUpdate)

I am using a "For Each" to iterate and update a legacy DB

For Each order In ordersToUpdate

  UpdateDB(order)

Next

I am having a LOCKING problem on the DB when the "ordersToUpdate" is large. Instead to puting a Threading.Thread.Sleep to pause, is there a proper way to break the list up into sections e.g iterating 100 at a time?

Author:Saif Khan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/4474195/iterate-typed-list-in-sections
yy