Reputation: 18117
I have QueueItem object with one property. I need to find it in ConcurrentBag list and change it value. How to do that?
QueueItemList = new ConcurrentBag<QueueItem>()
I can use linq to query object in ConcurrentBag like this
MyItem = QueueItemList.Where(match);
MyItem.Status = changeThis;
but is this thread safe?
Upvotes: 0
Views: 1083
Reputation: 13286
The Where
operation or any other collection operation is thread safe, for example if it wasn't thread safe there could be an error in the Where
operation if anyone changed the items count in other thread in the same time, but changing the Status
property is not related to the collection and it is not thread safe.
Upvotes: 1