void ProcessEventQueue() { // While processing the current queue, we need a new queue to store additional events that // might be generated during current queue events processing. Thanks to the gate mechanism, // events put in the new queue will be processed before the remaining events in the current // queue (but after processing of the event generating them is completed). // // For example, MouseDownEvent generates FocusOut, FocusIn, Blur and Focus events. And let's // say that FocusIn generates ValueChanged and GeometryChanged events. // // Without queue swapping, order of event processing would be MouseDown, FocusOut, FocusIn, // Blur, Focus, ValueChanged, GeometryChanged. It is not the same as order of event emission. // // With queue swapping, order is MouseDown, FocusOut, FocusIn, ValueChanged, GeometryChanged, // Blur, Focus. This preserve the order of event emission, and each event is completely // processed before processing the next event. Queue <EventRecord> queueToProcess = m_Queue; m_Queue = k_EventQueuePool.Get(); ExitGUIException caughtExitGUIException = null; try { processingEvents = true; while (queueToProcess.Count > 0) { EventRecord eventRecord = queueToProcess.Dequeue(); EventBase evt = eventRecord.m_Event; IPanel panel = eventRecord.m_Panel; try { ProcessEvent(evt, panel); } catch (ExitGUIException e) { Debug.Assert(caughtExitGUIException == null); caughtExitGUIException = e; } finally { // Balance the Acquire when the event was put in queue. evt.Dispose(); } } } finally { processingEvents = false; k_EventQueuePool.Release(queueToProcess); } if (caughtExitGUIException != null) { throw caughtExitGUIException; } }
private void ProcessEventQueue() { Queue <EventDispatcher.EventRecord> queue = this.m_Queue; this.m_Queue = EventDispatcher.k_EventQueuePool.Get(); ExitGUIException ex = null; try { while (queue.Count > 0) { EventDispatcher.EventRecord eventRecord = queue.Dequeue(); EventBase @event = eventRecord.m_Event; IPanel panel = eventRecord.m_Panel; try { this.ProcessEvent(@event, panel); } catch (ExitGUIException ex2) { Debug.Assert(ex == null); ex = ex2; } finally { @event.Dispose(); } } } finally { EventDispatcher.k_EventQueuePool.Release(queue); } bool flag = ex != null; if (flag) { throw ex; } }