static void Test() { MutilThreadReadWriterLock x = new MutilThreadReadWriterLock(); TimeSpan sp = new TimeSpan(0, 0, 1, 0); Console.WriteLine("Thread ID: {0}", id); Interlocked.Increment(ref id); while (true) { using (IDisposeState y = x.LockRead(sp)) { if (y.IsValid) { Console.WriteLine("Number: {0}", t); } } using (IDisposeState y = x.LockWrite(sp)) { if (y.IsValid) { t++; } } } }
public void Reset(bool isvalid, bool iswritelock, MutilThreadReadWriterLock rwl) { isValid = isvalid; isWriteLock = iswritelock; owner = rwl; }
public MutiThreadDisposeState(bool isvalid, bool iswritelock, MutilThreadReadWriterLock rwl) { isValid = isvalid; isWriteLock = iswritelock; owner = rwl; }