示例#1
0
        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++;
                    }
                }
            }
        }
示例#2
0
 public void Reset(bool isvalid, bool iswritelock, MutilThreadReadWriterLock rwl)
 {
     isValid     = isvalid;
     isWriteLock = iswritelock;
     owner       = rwl;
 }
示例#3
0
 public MutiThreadDisposeState(bool isvalid, bool iswritelock, MutilThreadReadWriterLock rwl)
 {
     isValid     = isvalid;
     isWriteLock = iswritelock;
     owner       = rwl;
 }