Hello,
I apologize if this is the wrong forum for this question. My scenario is this: I have a simulation engine that loads a large number of objects (~100,000) into List<t> objects.
The simulation fires off several threads. One of which iterates through a number of the objects updating their state. This happen once every minute. There is also a ThreadPool that is handling state changes coming in from WebService calls. Another thread is fired off every fifteen minutes to save all updated objects back to the database.
Needless to say, because collections are not thread-safe, I am getting errors that the collection has changed while enumerating it. My concern is that if I implement locking, I will end up waiting a long time for the threads to finish. This does not seem optimal. Scalability and performance are very important.
Another idea is to copy the collection into another array and save that array. The update thread can continue to process while the duplicate array is saved. This also seems cumbersome and a hack.
I guess what I am looking for is a cache layer that can track changes and update the database periodically without blocking reads or writes.
How are people handling this kind of architecture with LLBLGen?
Thanks,
Rick