/// <summary> /// Enqueues the specified event /// </summary> /// <param name="e">The event to enqueue.</param> public void Enqueue(Event e) { lock (syncRoot) { queue.Enqueue(e); #if NETCF syncEvent.Set(); while (waitCount != 0) Thread.Sleep(0); syncEvent.Reset(); #else Monitor.Pulse(syncRoot); #endif } if (synchronousEventSent != null && e.IsSynchronous) synchronousEventSent.WaitOne(); else Thread.Sleep(0); // give EventPump thread a chance to process the event }
/// <summary> /// Enqueues the specified event /// </summary> /// <param name="e">The event to enqueue.</param> public void Enqueue(Event e) { do { int cachedAddId = _addId; // Validate that we have are the current enqueuer if (Interlocked.CompareExchange(ref _addId, cachedAddId + 1, cachedAddId) != cachedAddId) continue; // Add to the collection _queue.Enqueue(e); // Wake up threads that may have been sleeping _mreAdd.Set(); break; } while (true); Thread.Sleep(1); // give EventPump thread a chance to process the event }
/// <summary> /// Enqueues the specified event /// </summary> /// <param name="e">The event to enqueue.</param> public void Enqueue( Event e ) { lock( this.syncRoot ) { this.queue.Enqueue( e ); Monitor.Pulse( this.syncRoot ); } if (this.synchronousEventSent != null && e.IsSynchronous) { this.synchronousEventSent.WaitOne(); } else { Thread.Sleep(0); // give EventPump thread a chance to process the event } }