// Runtime/ApplicationCore/Private/Windows/WindowsPlatformApplicationMisc.cpp voidFWindowsPlatformApplicationMisc::PumpMessages(bool bFromMainLoop) { if (!bFromMainLoop) { TGuardValue<bool> PumpMessageGuard(GPumpingMessagesOutsideOfMainLoop, true ); // Process pending windows messages, which is necessary to the rendering thread in some rare cases where D3D // sends window messages (from IDXGISwapChain::Present) to the main thread owned viewport window. WinPumpSentMessages(); return; }
// Determine if application has focus bool HasFocus = FApp::UseVRFocus() ? FApp::HasVRFocus() : FWindowsPlatformApplicationMisc::IsThisApplicationForeground();
// If editor thread doesn't have the focus, don't suck up too much CPU time. if(GIsEditor) { staticbool HadFocus=1; if(HadFocus && !HasFocus) { // Drop our priority to speed up whatever is in the foreground. SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); } elseif(HasFocus && !HadFocus) { // Boost our priority back to normal. SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); } if(!HasFocus) { // Sleep for a bit to not eat up all CPU time. FPlatformProcess::Sleep(0.005f); } HadFocus = HasFocus; } // ... }