CSharpTest.Net
Acquire Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure : Acquire Method

lck
timeout

Glossary Item Box

Acquires the lock within the timeout or throws TimeoutException

Syntax

Visual Basic (Declaration) 
Public Shared Function Acquire( _
   ByVal lck As ILockStrategy, _
   ByVal timeout As Integer _
) As ReadLock
C# 
public static ReadLock Acquire( 
   ILockStrategy lck,
   int timeout
)

Parameters

lck
timeout

Exceptions

ExceptionDescription
System.TimeoutExceptionThe exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C#Copy Code
using (ILockStrategy l = LockFactory.Create())
using (IDisposable r = ReadLock.Acquire(l, 0))
{
    r.Dispose();//since the using statement has the same boxed pointer to r, we are allowed to dispose
}
VB.NETCopy Code
Using l As ILockStrategy = LockFactory.Create()
    Using r As IDisposable = ReadLock.Acquire(l, 0)
            'since the using statement has the same boxed pointer to r, we are allowed to dispose
        r.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys