11 [__DynamicallyInvokable]
12 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
19 [SecuritySafeCritical]
20 [__DynamicallyInvokable]
21 public static extern void Enter(
object obj);
28 [__DynamicallyInvokable]
29 public static void Enter(
object obj, ref
bool lockTaken)
33 ThrowLockTakenException();
35 ReliableEnter(obj, ref lockTaken);
38 private static void ThrowLockTakenException()
44 [SecuritySafeCritical]
45 private static extern void ReliableEnter(
object obj, ref
bool lockTaken);
52 [SecuritySafeCritical]
53 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
54 [__DynamicallyInvokable]
55 public static extern void Exit(
object obj);
62 [__DynamicallyInvokable]
65 bool lockTaken =
false;
75 [__DynamicallyInvokable]
76 public static void TryEnter(
object obj, ref
bool lockTaken)
80 ThrowLockTakenException();
82 ReliableEnterTimeout(obj, 0, ref lockTaken);
93 [__DynamicallyInvokable]
94 public static bool TryEnter(
object obj,
int millisecondsTimeout)
96 bool lockTaken =
false;
97 TryEnter(obj, millisecondsTimeout, ref lockTaken);
101 private static int MillisecondsTimeoutFromTimeSpan(
TimeSpan timeout)
104 if (num < -1 || num >
int.MaxValue)
118 [__DynamicallyInvokable]
121 return TryEnter(obj, MillisecondsTimeoutFromTimeSpan(timeout));
132 [__DynamicallyInvokable]
133 public static void TryEnter(
object obj,
int millisecondsTimeout, ref
bool lockTaken)
137 ThrowLockTakenException();
139 ReliableEnterTimeout(obj, millisecondsTimeout, ref lockTaken);
149 [__DynamicallyInvokable]
154 ThrowLockTakenException();
156 ReliableEnterTimeout(obj, MillisecondsTimeoutFromTimeSpan(timeout), ref lockTaken);
160 [SecuritySafeCritical]
161 private static extern void ReliableEnterTimeout(
object obj,
int timeout, ref
bool lockTaken);
169 [SecuritySafeCritical]
170 [__DynamicallyInvokable]
177 return IsEnteredNative(obj);
182 private static extern bool IsEnteredNative(
object obj);
186 private static extern bool ObjWait(
bool exitContext,
int millisecondsTimeout,
object obj);
200 [SecuritySafeCritical]
201 public static bool Wait(
object obj,
int millisecondsTimeout,
bool exitContext)
207 return ObjWait(exitContext, millisecondsTimeout, obj);
222 public static bool Wait(
object obj,
TimeSpan timeout,
bool exitContext)
224 return Wait(obj, MillisecondsTimeoutFromTimeSpan(timeout), exitContext);
236 [__DynamicallyInvokable]
237 public static bool Wait(
object obj,
int millisecondsTimeout)
239 return Wait(obj, millisecondsTimeout, exitContext:
false);
251 [__DynamicallyInvokable]
254 return Wait(obj, MillisecondsTimeoutFromTimeSpan(timeout), exitContext:
false);
264 [__DynamicallyInvokable]
265 public static bool Wait(
object obj)
267 return Wait(obj, -1, exitContext:
false);
272 private static extern void ObjPulse(
object obj);
278 [SecuritySafeCritical]
279 [__DynamicallyInvokable]
280 public static void Pulse(
object obj)
291 private static extern void ObjPulseAll(
object obj);
297 [SecuritySafeCritical]
298 [__DynamicallyInvokable]
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static void TryEnter(object obj, TimeSpan timeout, ref bool lockTaken)
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object,...
static bool Wait(object obj)
Releases the lock on an object and blocks the current thread until it reacquires the lock.
static void PulseAll(object obj)
Notifies all waiting threads of a change in the object's state.
static bool TryEnter(object obj)
Attempts to acquire an exclusive lock on the specified object.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
Provides a mechanism that synchronizes access to objects.
static bool Wait(object obj, int millisecondsTimeout, bool exitContext)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
static bool Wait(object obj, TimeSpan timeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
static bool TryEnter(object obj, TimeSpan timeout)
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.
Cer
Specifies a method's behavior when called within a constrained execution region.
SecurityAction
Specifies the security actions that can be performed using declarative security.
static void Enter(object obj)
Acquires an exclusive lock on the specified object.
Provides information about, and means to manipulate, the current environment and platform....
static bool IsEntered(object obj)
Determines whether the current thread holds the lock on the specified object.
static void Enter(object obj, ref bool lockTaken)
Acquires an exclusive lock on the specified object, and atomically sets a value that indicates whethe...
static void Exit(object obj)
Releases an exclusive lock on the specified object.
static bool Wait(object obj, TimeSpan timeout, bool exitContext)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
static bool Wait(object obj, int millisecondsTimeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
MethodImplOptions
Defines the details of how a method is implemented.
static void TryEnter(object obj, ref bool lockTaken)
Attempts to acquire an exclusive lock on the specified object, and atomically sets a value that indic...
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Pulse(object obj)
Notifies a thread in the waiting queue of a change in the locked object's state.
Represents a time interval.To browse the .NET Framework source code for this type,...
Consistency
Specifies a reliability contract.
static void TryEnter(object obj, int millisecondsTimeout, ref bool lockTaken)
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified obj...
static bool TryEnter(object obj, int millisecondsTimeout)
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified obj...