System.ArgumentOutOfRangeExpection
Hello, I am getting this error only when running
Parallel.ForEach
with StringBuilder
, other times it does not run this error anyone can help? Thank you
My task was to find StringBuilder
& Parallel.ForEach
speed differents
Code Attached below3 Replies
StringReader
isn't thread-safe. It is not safe to append to it from multiple threads at the same time
Why are you even trying to use Parallel
there? At best, that would meant that your posts would be appended in random order. Or rather, the individual Append
calls would be done in a random order, so your HTML would be very broken
Note that your string +=
isn't thread-safe either. It's possible that some of those appends will be droppedThe task was to see different between
foreach
and Parallel.Foreach
I see, we were not told about thread-safe
Will come up with another example than, thank you!Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View