From bec9d3c223a3c72222d3ee48bf2c40e85d780d32 Mon Sep 17 00:00:00 2001 From: kipp Date: Mon, 6 Jul 1998 17:41:27 +0000 Subject: [PATCH] Changed the event loop to install a timer to make sure that the net will always get some cycles --- webshell/tests/viewer/winmain.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/webshell/tests/viewer/winmain.cpp b/webshell/tests/viewer/winmain.cpp index 27448f114db9..3e8530548892 100644 --- a/webshell/tests/viewer/winmain.cpp +++ b/webshell/tests/viewer/winmain.cpp @@ -32,6 +32,7 @@ #include "prenv.h" #include "nsIScriptContext.h" #include "nsIScriptContextOwner.h" +#include "nsITimer.h" // Debug Robot options static int gDebugRobotLoads = 5000; @@ -304,6 +305,18 @@ void nsWin32Viewer::Destroy(WindowData* wd) nsViewer::Destroy(wd); } +static nsITimer* gNetTimer; + +static void +PollNet(nsITimer *aTimer, void *aClosure) +{ + NET_PollSockets(); + NS_IF_RELEASE(gNetTimer); + if (NS_OK == NS_NewTimer(&gNetTimer)) { + gNetTimer->Init(PollNet, nsnull, 1000 / 50); + } +} + int PASCAL RunViewer(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCmdShow, nsWin32Viewer* aViewer) { @@ -317,20 +330,16 @@ RunViewer(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCmdShow, ns // Process messages MSG msg; - BOOL bContinue = TRUE; - - while (bContinue) { - if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (!JSConsole::sAccelTable || + PollNet(0, 0); + while (::GetMessage(&msg, NULL, 0, 0)) { + if (!JSConsole::sAccelTable || !gConsole || !gConsole->GetMainWindow() || !TranslateAccelerator(gConsole->GetMainWindow(), JSConsole::sAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - bContinue = (msg.message != WM_QUIT); + TranslateMessage(&msg); + DispatchMessage(&msg); + NET_PollSockets(); } - NET_PollSockets(); } aViewer->CleanupViewer(dl);