Imports many of the useful extension methods from v5 that are also used in umbraMVCo to begin the
MVC integration. Imported the unit tests associated with each of these imported classes.
This commit is contained in:
34
src/Umbraco.Core/WriteLock.cs
Normal file
34
src/Umbraco.Core/WriteLock.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a convenience methodology for implementing locked access to resources.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Intended as an infrastructure class.
|
||||
/// </remarks>
|
||||
public class WriteLock : IDisposable
|
||||
{
|
||||
private readonly ReaderWriterLockSlim _rwLock;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WriteLock"/> class.
|
||||
/// </summary>
|
||||
/// <param name="rwLock">The rw lock.</param>
|
||||
public WriteLock(ReaderWriterLockSlim rwLock)
|
||||
{
|
||||
_rwLock = rwLock;
|
||||
_rwLock.EnterWriteLock();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
_rwLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user