コード例 #1
0
 /// <summary>
 /// Coloca un objeto en la cola
 /// </summary>
 /// <param name="m">El objeto a colocar en la cola</param>
 public void put(Event m)
 {
     monitor.Enter();
     queue.Enqueue(m);
     itemCount++;
     monitor.Pulse();
     monitor.Exit();
 }
コード例 #2
0
 /// <summary>
 /// Coloca un mensaje en la cola
 /// </summary>
 /// <param name="m">el mensaje a colocar en la cola</param>
 public void put(NetMessage m)
 {
     monitor.Enter();
     queue.Enqueue(m);
     itemCount++;
     monitor.Pulse();
     monitor.Exit();
 }
コード例 #3
0
        public void MonitorSimpleWaitPulse()
        {
            object locker   = new object();
            bool   go       = false;
            bool   gotPulse = false;

            var thread = new Thread(() =>
            {
                lock (locker)
                    while (!go)
                    {
                        Monitor2.Wait(locker);
                    }

                gotPulse = true;
            });

            thread.Start();

            lock (locker)
            {
                go = true;
                Monitor2.Pulse(locker);
            }

            Assert.IsTrue(thread.Join(250));
            Assert.IsTrue(gotPulse);
        }
コード例 #4
0
 public void EnqueueItem(Action item)
 {
     lock (_locker)
     {
         _itemQ.Enqueue(item);     // We must pulse because we're
         Monitor2.Pulse(_locker);  // changing a blocking condition.
     }
 }
コード例 #5
0
            public void Dispose()
            {
                _done = true;

                lock (_cancel)
                {
                    Monitor2.Pulse(_cancel);
                }
            }