/// <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(); }
/// <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(); }
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); }
public void EnqueueItem(Action item) { lock (_locker) { _itemQ.Enqueue(item); // We must pulse because we're Monitor2.Pulse(_locker); // changing a blocking condition. } }
public void Dispose() { _done = true; lock (_cancel) { Monitor2.Pulse(_cancel); } }