void () { assertDispatchThreadWithoutWriteAccess(); IdeEventQueue eventQueue = IdeEventQueue.getInstance(); try (AccessToken ignored = ThreadContext.resetThreadContext()) { while (true) { AWTEvent event = eventQueue.peekEvent(); if (event == null) break; event = eventQueue.getNextEvent(); if (event instanceof InvocationEvent) { eventQueue.dispatchEvent(event); } } } }