public void ProcessEvents() { var msg = new MSG(); while (!_done) // Loop That Runs While done=FALSE { if (User32.PeekMessage(ref msg, _handle, 0, 0, 0x0001)) // Is There A Message Waiting? { if (msg.Message == WindowsMessage.Quit) // Have We Received A Quit Message? { _done = true; // If So done=TRUE } else // If Not, Deal With Window Messages { User32.TranslateMessage(ref msg); User32.DispatchMessage(ref msg); } } else // If There Are No Messages { if (Update != null) Update(); if (Render != null) Render(); SwapBuffers(); } } }
public static extern bool TranslateMessage(ref MSG msg);
public static extern int GetMessage(ref MSG msg, IntPtr windowHandle, int messageFilterMin, int messageFilterMax);
public static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
public static extern IntPtr DispatchMessage(ref MSG msg);