If you are targetting .Net 4 there are a few options in System.Collections.Concurrent Namespace
You could use ConcurrentBag<T>
in this case instead of List<T>
More Related Contents:
- What’s the best way of implementing a thread-safe Dictionary?
- C# thread safety with get/set
- System.InvalidOperationException: Collection was modified
- Thread Safe Properties in C#
- Create Dynamic Threads in c# [closed]
- What is the difference between a field and a property?
- Communicate between two windows forms in C#
- How to get the list of properties of a class?
- What does the => operator mean in a property?
- Difference between Property and Field in C# 3.0+
- What does a lock statement do under the hood?
- How do I overload the square-bracket operator in C#?
- Are C# arrays thread safe?
- How to create a task (TPL) running a STA thread?
- How can I find a specific element in a List?
- How do I override List’s Add method in C#?
- Why do I need a memory barrier?
- C# Sortable collection which allows duplicate keys
- Is a reference assignment threadsafe?
- Why do C# collection initializers work this way?
- Does the Enumerator of a Dictionary return key value pairs in the order they were added?
- Are you there, asynchronously written value?
- Case-INsensitive Dictionary with string key-type in C#
- Is this use of Parallel.ForEach() thread safe?
- How to implement virtual static properties?
- Compare Two Lists Via One Property Using LINQ
- How to set value of property where there is no setter
- How to hide some members of an interface
- SqlConnection Thread-Safe?
- How to check whether all properties of an object are null or empty?