Пример #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;
 }