示例#1
0
        private void TakeTask()
        {
            lock (this.SyncObject1)
            {
                if (this.Value != "put")
                {
                    Monitor.Wait(this.SyncObject1);
                }

                this.Value = "taken";
            }
        }
示例#2
0
        /// <summary>
        /// Releases the writer, another writer my continue or all the readers may start reading
        /// </summary>
        public void ReleaseWriter()
        {
            writePermission.Release();             // >> REMOVES WRITER FROM WRITE QUEUE

            lock (lockObject) {
                if (readersWaiting > 0)
                {
                    Monitor.Wait(lockObject);
                }
            }

            writerTS.Release();
        }
 public static bool Wait(object obj, int timeout)
 {
     return(SMonitor.Wait(obj, timeout));
 }
 public static void Wait(object obj)
 {
     SMonitor.Wait(obj);
 }