SpinLock.TryEnter Method (TimeSpan, Boolean)
Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.TimeSpan
True if the lock is acquired; otherwise, false. lockTaken must be initialized to false prior to calling this method.
timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue milliseconds.
The lockTaken argument must be initialized to false prior to calling TryEnter.
Thread ownership tracking is enabled, and the current thread has already acquired this lock.
Unlike Enter, TryEnter will not block indefinitely waiting for the lock to be available. It will block until either the lock is available or until the timeout has expired.
Available since 8
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Available since 8.1