Breyta

Deila með


Lock.EnterScope Method

Definition

Enters the lock, waiting if necessary until the lock can be entered.

public:
 System::Threading::Lock::Scope EnterScope();
public System.Threading.Lock.Scope EnterScope ();
member this.EnterScope : unit -> System.Threading.Lock.Scope
Public Function EnterScope () As Lock.Scope

Returns

A Lock.Scope that can be disposed to exit the lock.

Exceptions

The lock has reached the limit of repeated entries by the current thread. The limit is implementation-defined and is intended to be high enough that it would not be reached in normal situations.

Remarks

If the lock can't be entered immediately, the method waits until the lock can be entered. If the lock is already held by the current thread, the lock is entered again. To fully exit the lock and allow other threads to enter the lock, the current thread should dispose the returned Lock.Scope to exit the lock as many times as it has entered the lock.

This method is intended to be used with a language construct that automatically disposes the Lock.Scope, such as the C# using keyword.

For more information, see the Remarks for Lock.

Applies to