private void MessageLoop() { _threadID = (uint)Win32.GetCurrentThreadId(); ManagerdThreadID = Thread.CurrentThread.ManagedThreadId; var msg = new Win32.MSG(); Win32.PeekMessage(ref msg, IntPtr.Zero, Win32.WM_USER, Win32.WM_USER, Win32.PM_NOREMOVE); IsMessageLoopBegin = true; while (Win32.GetMessage(ref msg, IntPtr.Zero, 0, 0)) { if (msg.message == Win32.WM_QUIT) return; if (ThreadMessageProc(ref msg)) { continue; } Win32.TranslateMessage(ref msg); foreach (var messageFilter in _messageFilters) { messageFilter.PreFilterMessage(ref msg); } Win32.DispatchMessage(ref msg); } }