Hi All,
I'm using vb.net as my codebehind lang. and the following code is
being executed in my aspx.vb page to stamp a DB row.
Dim oStatsInfo As New StatsInfo(CartI D, Batch, Set, Num, 0, 0, 0, 1,
0, 1)
Dim oStatsStamp As New Stats(_DataSour ce, oStatsInfo)
Dim tStamp As New Threading.Threa d(AddressOf
oStatsStamp.Sta mpStatsList)
tStamp.Start()
The code calls a stored proc which stamps a row in the database with
the values for the StatsInfo class using an UPDATE statement. If no
rows are affected (@@ROWCOUNT = 0) then a new row is added to the
database using an INSERT.
Now what is weird is that on rare occasions it looks like .Start() is
spawning to consecutive threads instead of one. I say this because two
rows end up in the database with consecutive ID numbers (generated
automaticly as the PK for the row).
So it looks like two threads get created they both go to call the SP
and while the 1st thread is getting ready to run the INSERT (because
there are no rows yet) the second thread calls the SP, it tries the
UPDATE, sees no rows (because thread 1 hasn't finished the INSERT
yet), and runs the INSERT as well.
Does anyone know if it's possible for the .Start call to accidentally
create two threads? Is that even what is happening.
Thanks for any help you can offer.
Cheers,
Mike Gorgone
Senior Software Engineer
PictureU
mg******@pictur eu.com