1

Possible Duplicate:
C# version of java's synchronized keyword?

I know that when working with a session in Java, you were always supposed to surround use of the session with a synchronized block incase the user would load your page with two browsers at the same time.

Is there an equivalent keyword/block in C# for doing the same thing?

Community
  • 1
  • 1
leeand00
  • 25,510
  • 39
  • 140
  • 297
  • 2
    Duplicate - see: http://stackoverflow.com/questions/541194/c-version-of-javas-synchronized-keyword – dugas Mar 30 '11 at 21:03

1 Answers1

4

You could use the lock statement or decorate a method with the [MethodImpl(MethodImplOptions.Synchronized)] attribute to allow access to this block/method only from a single thread at a time.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928