{"action":"closed","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/19524","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/19524/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/19524/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/19524/events","html_url":"https://github.com/dotnet/roslyn/issues/19524","id":228856590,"number":19524,"title":"VB SyncLock error ?","user":{"login":"vbcodec","id":2153877,"avatar_url":"https://avatars0.githubusercontent.com/u/2153877?v=3","gravatar_id":"","url":"https://api.github.com/users/vbcodec","html_url":"https://github.com/vbcodec","followers_url":"https://api.github.com/users/vbcodec/followers","following_url":"https://api.github.com/users/vbcodec/following{/other_user}","gists_url":"https://api.github.com/users/vbcodec/gists{/gist_id}","starred_url":"https://api.github.com/users/vbcodec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbcodec/subscriptions","organizations_url":"https://api.github.com/users/vbcodec/orgs","repos_url":"https://api.github.com/users/vbcodec/repos","events_url":"https://api.github.com/users/vbcodec/events{/privacy}","received_events_url":"https://api.github.com/users/vbcodec/received_events","type":"User","site_admin":false},"labels":[{"id":166673288,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-15T21:50:04Z","updated_at":"2017-06-15T20:31:20Z","closed_at":"2017-06-15T20:31:20Z","body":"```\r\nPublic Class DBConnectionLink\r\n    Shared Errors As New List(Of AppError)\r\n\r\n    Public Shared Sub WriteErrors()\r\n        SyncLock Errors\r\n            For Each E In Errors\r\n                Try\r\n                    MonitoringError(E)\r\n                Catch ex As Exception\r\n                End Try\r\n             Next\r\n             Errors.Clear()\r\n        End SyncLock\r\n    End Sub\r\n\r\n    Friend Shared Sub AddError(Err As AppError)\r\n        SyncLock Errors\r\n            Errors.Add(Err)\r\n        End SyncLock\r\n    End Sub\r\n\r\nEnd Class\r\n```\r\n\r\nFunction WriteError is called by single background thread, while AddError by other working thread(s)\r\nCalling WriteErrors throw (sometimes) exception:\r\n \r\n```\r\nMessage: Collection was modified; enumeration operation may not execute. \r\nStack: \r\nin System.ThrowHelper.ThrowInvalidOperationException\r\nin System.Collections.Generic.List`1+Enumerator.MoveNextRare\r\nin System.Collections.Generic.List`1+Enumerator.MoveNext\r\nin Tools.DBConnectionLink.WriteErrors \r\n```\r\n "}}
{"actor":{"display_login":"jaredpar"}}