Aha, code has the datatable varaible created as Public Shared for some
reason.
Thanks for hte hint :)
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
| Seems like a multithreading problem.
|
| What's the scope of the DataTable in question? Is it stored in the
| Application? In a shared/static field? In the Session object, a local var
of
| the calling function? The Cache?
|
| My guess is that it's shared accross multiple users via the Cache,
| Application or a static/shared field....and you're getting 1 request
| modifying the table at the same time as another one is trying to clear it.
|
| Whenever you deal with resources across multiple threads, you need to be
| careful to syncrhonize any volatile operation..
|
| Specifically, this is code within Clear:
|
| for (int num1 = 0; num1 < this.rowCollection.Count; num1++)
| {
| DataRow row1 = this.rowCollection[num1];
| row1.oldRecord = -1;
| row1.newRecord = -1;
| //do more stuff with row1
| }
|
|
| if this.rowCollection.Count returns 100....
| it starts to loop..by the time it reachs the 99, another thread might have
| deleted row 99, and then you're in the mess you're in :)
|
| Simply placing locks around the volatile code is the simplest solution,
| though I would recommend a more thorough examination..
|
| karl
|
| --
|
http://www.openmymind.net/
|
http://www.fuelindustries.com/
|
|
| "Adrian Parker" <ap******@nospam.nospamwrote in message
| news:%2****************@TK2MSFTNGP05.phx.gbl...
| We've suddenly started getting a problem with a call to clear the
contents
| of a DataTable. This is on a live customer site that's been working
fine
| until yesterday. As far as we know they've not changed or updated the
| server in any way.
| >
| "There is no row at position 42"
| >
| at System.Data.RBTree`1.GetNodeByIndex(int32 userIndex)
| at System.Data.DataTable.Clear(Boolean clearAll)
| at system.Data.DataTable.Clear()
| >
| Public Overrides Sub GetTable(ByRef aTbl As DataTable, ByVal aSQL As
| String)
| If aTbl Is Nothing Then
| aTbl = New DataTable
| Else
| aTbl.Clear()
| End If
| ' code to retrieve data
| End Sub
| >
| >
| >
| Any ideas ?
| --
| Adrian Parker
| Ingenuity At Work Ltd
| >
| >
|
|