Multi threading static method and possible locking

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I have a static method that I use for data access. This particular
method reads x number of rows and then updates these rows with a read
= 1 flag. I access this method with several threads and I guess that
one thread (thread A) could read rows and then the next thread (thread
B) would read the same rows BEFORE the first thread has updated
"it's" (all the rows selected by thread A) rows as read - right? Will
it help just wrapping this complete method (the one that read and then
updates the rows as read) in a lock or is that unnecessary in this
case?

.



Relevant Pages

  • Re: Architecture for a distributed app
    ... complicated are updates likely to be (maybe posting a CD with explicit ... web option. ... The webpages are probably lighter than data access and ... clunky methods like remote dial-up access ...
    (microsoft.public.dotnet.general)
  • Re: Access Front End, SQL Back End
    ... Work in disconnected mode, where data access is done read-only, and ... updates are posted back via stored procedures. ... Fetch only required ...
    (microsoft.public.access.externaldata)
  • Static v Instance in DAL
    ... use a static method, particularly in the context of a DAL. ... examples I have seen instantiation of the Data Access Object. ... to perform static operations? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread-safe static methods/variables
    ... > while created/modified in a static method, are in fact created on the heap ... the variables it creates are specific heap instances and ... The DAAB (Data Access Application block) is ...
    (microsoft.public.dotnet.framework.aspnet)