I have a bit of code that works like this on a list of obj objects called ListofObjects:
List NewListofObjects();
Parall
Is this because my
NewListofObjects.Add(newobj)method is not threadsafe?
Correct. It is not threadsafe.
Any instance members are not guaranteed to be thread safe.
That's from MSDN referring to List (scroll to the section titled "Thread Safety").
If so, how can I make it threadsafe?
Use a concurrent collection, like ConcurrentBag