You have a couple of problems.
, batchCollection, recordsCollection , .
.
ArrayList recordsCollection = new ArrayList();
ArrayList batchCollection = null;
int idx = 0;
while(true)
{
lock (recordsCollection)
{
recordsCollection.Add(batchCollection);
}
int capturedIndex = idx;
ThreadPool.QueueUserWorkItem(delegate
{
ArrayList range;
lock (recordsCollection)
{
range = recordsCollection.GetRange(capturedIndex, 1);
}
ProcessCollection(range);
});
idx++;
}
, , , ...
List<List<Record>> recordsCollection = new ArrayList();
List<Record> batchCollection = null;
while(true)
{
recordsCollection.Add(batchCollection);
List<List<Record>> range = new List<List<Record>>();
range.Add(batchCollection);
ThreadPool.QueueUserWorkItem(delegate
{
ProcessCollection(range);
});
}