I have a LINQ statement that returns only certain objects from a collection. I keep getting "collection has been modified" errors, because other threads are modifying the "Checks" collection at the same time that this LINQ statement is trying to pull some numbers.
Here's the procedure where I keep getting the "collection was modified" errors:
vb.net Code:
Public Function GetActualCheckCount() As Int32
Dim RetryCount As Int32 = 0
Retry: Try
Return (From x In Checks Where Not x.Status = 3).Count
Catch ex0708 As Exception
If ex0708.Message.ToLower.Contains("collection was modified") AndAlso RetryCount < 8 Then
RetryCount += 1
GoTo Retry
End If
End Try
End Function