In version 1.0.2, there was a race condition:
- The code that processes files in parallel was previously using a
HashSet to collect results.
HashSet<T> is not thread-safe: when multiple threads add items at the same time, it can corrupt internal state or throw exceptions.
- That collection has been replaced with a
ConcurrentBag<T>, which is specifically designed for concurrent writes from multiple threads without additional locking.
In practical terms:
- Before: parallel file-processing tasks were all writing into a shared
HashSet, risking intermittent crashes, missing entries, or corrupted data under load.
- After: the same work is still done in parallel, but results go into a
ConcurrentBag, so each thread can safely add items without stepping on each other.
So the race condition was resolved by switching to a thread-safe collection for shared parallel file processing, ensuring deterministic and stable behavior during synchronization.