You are creating multiple threads in you application that will execute the same method. You need to synchronize access to a block of code within the method so that no two threads execute the block at the same time. What should you do?
A.
Add a SynchronizationAttribute attribute to the method that the multiple threads will call.
B.
Call the Monitor.Enter method before the block of code you want to synchronize, and then call the Monitor.Exit method after the block of code you want to synchronize.
C.
Use the Thread.BeginCriticalRegion method before the block of code you want to synchronize and the Thread.EndCriticalRegion method after the block of code you want to synchronize.
D.
Call the Interlocket.Increment method before the block of code you want to synchronize, and then call the Interlocked.Decrement method after the block of code you want to synchronize.