C# Class Subtext.Framework.Threading.TimedLock

Class provides a nice way of obtaining a lock that will time out with a cleaner syntax than using the whole Monitor.TryEnter() method.
Adapted from Ian Griffiths article http://www.interact-sw.co.uk/iangblog/2004/03/23/locking and incorporating suggestions by Marek Malowidzki as outlined in this blog post http://www.interact-sw.co.uk/iangblog/2004/05/12/timedlockstacktrace
Datei anzeigen Open project: ayende/Subtext Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Disposes of this lock.

Lock ( object o ) : TimedLock

Attempts to obtain a lock on the specified object for up to 10 seconds.

Lock ( object o, System.TimeSpan timeout ) : TimedLock

Attempts to obtain a lock on the specified object for up to the specified timeout.

Private Methods

Method Description
TimedLock ( object o ) : System

Method Details

Dispose() public method

Disposes of this lock.
public Dispose ( ) : void
return void

Lock() public static method

Attempts to obtain a lock on the specified object for up to 10 seconds.
public static Lock ( object o ) : TimedLock
o object
return TimedLock

Lock() public static method

Attempts to obtain a lock on the specified object for up to the specified timeout.
public static Lock ( object o, System.TimeSpan timeout ) : TimedLock
o object
timeout System.TimeSpan
return TimedLock