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?
The
Whereoperation or any other collection operation is thread safe, for example if it wasn’t thread safe there could be an error in theWhereoperation if anyone changed the items count in other thread in the same time, but changing theStatusproperty is not related to the collection and it is not thread safe.