本文整理汇总了C#中System.Threading.ReaderWriterLock.RestoreLock方法的典型用法代码示例。如果您正苦于以下问题:C# ReaderWriterLock.RestoreLock方法的具体用法?C# ReaderWriterLock.RestoreLock怎么用?C# ReaderWriterLock.RestoreLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.ReaderWriterLock
的用法示例。
在下文中一共展示了ReaderWriterLock.RestoreLock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestReleaseRestoreWriterLock
public void TestReleaseRestoreWriterLock ()
{
rwlock = new ReaderWriterLock ();
rwlock.AcquireWriterLock (500);
rwlock.AcquireWriterLock (500);
Assert.IsTrue (rwlock.IsWriterLockHeld);
LockCookie co = rwlock.ReleaseLock ();
RunThread (new ThreadStart (AcquireLock_readerWorks));
rwlock.RestoreLock (ref co);
RunThread (new ThreadStart (AcquireLock_readerFails));
rwlock.ReleaseWriterLock ();
Assert.IsTrue (rwlock.IsWriterLockHeld);
rwlock.ReleaseWriterLock ();
Assert.IsTrue (!rwlock.IsWriterLockHeld);
}
示例2: TestReleaseRestoreReaderLock
public void TestReleaseRestoreReaderLock ()
{
rwlock = new ReaderWriterLock ();
rwlock.AcquireReaderLock (500);
rwlock.AcquireReaderLock (500);
Assert ("r1", rwlock.IsReaderLockHeld);
LockCookie co = rwlock.ReleaseLock ();
RunThread (new ThreadStart (AcquireLock_writerWorks));
rwlock.RestoreLock (ref co);
RunThread (new ThreadStart (AcquireLock_writerFails));
rwlock.ReleaseReaderLock ();
Assert ("r2", rwlock.IsReaderLockHeld);
rwlock.ReleaseReaderLock ();
Assert ("r3", !rwlock.IsReaderLockHeld);
}