/// <summary> /// Acquires write lock for the specified object. /// </summary> /// <typeparam name="T">The type of the object to be locked.</typeparam> /// <param name="obj">The object to be locked.</param> /// <param name="timeout">The amount of time to wait for the lock.</param> /// <returns>The acquired write lock.</returns> /// <exception cref="TimeoutException">The lock cannot be acquired during the specified amount of time.</exception> public static Lock.Holder AcquireWriteLock <T>(this T obj, TimeSpan timeout) where T : class => Lock.WriteLock(obj.GetReaderWriterLock()).Acquire(timeout);
/// <summary> /// Acquires write lock for the specified object. /// </summary> /// <typeparam name="T">The type of the object to be locked.</typeparam> /// <param name="obj">The object to be locked.</param> /// <returns>The acquired write lock.</returns> public static Lock.Holder AcquireWriteLock <T>(this T obj) where T : class => Lock.WriteLock(obj.GetReaderWriterLock()).Acquire();