The problem is that you have one StringBuilder (sbRecord
) that is shared by the parallel threads. You need to move sbRecord
to be a local variable inside RunLoop
.
I think you also want the .AppendLine(...)
calls in CreateFeedFile
to be on sbFile
rather than sbRecord
.