If you use streams with a data set, this error will occur.
In my case, I was trying to create a new row for a data set in a method that was running in threads.
One way was to use SyncLock around a method that creates a string or another way (and probably even better) to create strings outside of threads.
Basically my code looks something like this:
Dim elements As New List(Of element) Dim dataRows As New List(Of MyDataSet.Row) For i As Integer = 0 To elements.Count - 1 dataRows.Add(Me.Ds.Elements.NewElementsRow) Next Parallel.For(0, elements.Count, Sub(i As Integer) Me.CreateElementRow(elements(i), dataRows(i)) End Sub)
In the CreateElementRow method , I do a lot of computation in threads.
Hope this helps.
mrc Dec 08 '15 at 11:01 2015-12-08 11:01
source share