예제 #1
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void CBrowserEvents::BeforeNavigate(CString & szUrl)
{
    ATLTRACE(_T("[Pagetest] - CBrowserEvents::BeforeNavigate - url = %s"), (LPCTSTR)szUrl);
    
    CheckReadyState();
    
	// only count http and https url's (skip about: and javascript:)
	if( !szUrl.Left(4).CompareNoCase(_T("http")) )
	{
		EnterCriticalSection(&cs);
		
		// if we don't have a page we're tracking yet, start now
		if( !active && available )
		{
			LeaveCriticalSection(&cs);
			
			DoStartup(szUrl, true);
			
			EnterCriticalSection(&cs);
			navigatedURLs.AddTail(szUrl);
			LeaveCriticalSection(&cs);

			CString buff;
			buff.Format(_T("[Pagetest] * Before Navigate - %s\n"), (LPCTSTR)szUrl);
			OutputDebugString(buff);
			
			CheckStuff();

			// create an event for the page
			CPageEvent * p = new CPageEvent(currentDoc);
			AddEvent(p);

			EnterCriticalSection(&cs);
		}
		else if(active)
		{
			CString buff;
			buff.Format(_T("[Pagetest] * Before Navigate - %s\n"), (LPCTSTR)szUrl);
			OutputDebugString(buff);
			
			navigatedURLs.AddTail(szUrl);
			LeaveCriticalSection(&cs);
			
			CheckStuff();

			// track the document that everything belongs to
			EnterCriticalSection(&cs);
			currentDoc = nextDoc;
			nextDoc++;

			QueryPerfCounter(lastRequest);
			lastActivity = lastRequest;
		}

		LeaveCriticalSection(&cs);
	}
}
예제 #2
0
파일: xdll.cpp 프로젝트: uvbs/XDLL
extern "C" void WINAPI Startup()
{
	#ifdef NEED_LOG
	OutputDebugString(_T("XD:void WINAPI Startup()"));
	#endif
	//EnterCriticalSection(&_Module.m_csStaticDataInit);
	if( g_bIsRunning == false )
	{ 
		AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
		//::MessageBox(NULL, _T("F**k"), _T("F**k"), MB_OK); 
		DoStartup();
		g_bIsRunning = true;
	} 
	//LeaveCriticalSection(&_Module.m_csStaticDataInit);
}
예제 #3
0
init_mac_interface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheText = NULL;
   TheWindow = NULL;
   TheVScrollBar = NULL;
   TheHScrollBar = NULL;
   
   /*======================================*/
   /* Place any selected files in buffers. */
   /*======================================*/
   
   DoStartup();
   
   /*=======================*/
   /* Initialize the Scrap. */
   /*=======================*/
   
   InitializeScrap();
   
   /*=========================*/
   /* Set up for MultiFinder. */
   /*=========================*/
   
   MultiFinderSetup();
   
   /*===================================*/
   /* Set up routers for the interface. */
   /*===================================*/
   
   SetUpRouters();
   
   /*==================================================================*/
   /* Set up hook between CLIPS command loop and interface event loop. */
   /*==================================================================*/
   
   set_event_function(MainEvent);
   
   /*==================================================================*/
   /* Add execution function to update interface between rule firings. */
   /*==================================================================*/
   
   add_exec_function("macint",mac_exec_function);
  }
예제 #4
0
/*-----------------------------------------------------------------------------
  Background thread for managing the state of the agent
-----------------------------------------------------------------------------*/
void CurlBlastDlg::ThreadProc(void)
{
    LoadSettings();

    // configure the desktop resolution
    WaitForSingleObject(testingMutex, INFINITE);
    SetupScreen();
    ReleaseMutex(testingMutex);

    // wait for the statup delay
    SetStatus(_T("Starting up..."));
    DWORD ms = startupDelay;
    while( ms > 0 && WaitForSingleObject(hMustExit,0) == WAIT_TIMEOUT) {
        Sleep(500);
        ms -= 500;
    }

    // launch the watchdog
    TCHAR path[MAX_PATH];
    GetModuleFileName(NULL, path, MAX_PATH);
    lstrcpy(PathFindFileName(path), _T("wptwatchdog.exe"));
    CString watchdog;
    watchdog.Format(_T("\"%s\" %d"), path, GetCurrentProcessId());
    HANDLE process = NULL;
    LaunchProcess(watchdog, &process);
    if (process)
        CloseHandle(process);

    if (WaitForSingleObject(hMustExit,0) == WAIT_TIMEOUT) {
        DoStartup();
    }

    // handle the periodic cleanup until it is time to exit
    Alive();
    DWORD msCleanup = 500;
    DWORD msTemp = 20000;
    while(WaitForSingleObject(hMustExit,0) == WAIT_TIMEOUT) {
        if (!msCleanup) {
            CloseDialogs();
            KillProcs();
            msCleanup = 500;
        } else
            msCleanup -= 500;

        if (!msTemp) {
            if (WaitForSingleObject(testingMutex, 0) != WAIT_TIMEOUT) {
                ClearTemp();
                msTemp = 20000;
                ReleaseMutex(testingMutex);
            }
        } else
            msTemp -= 500;

        CheckAlive();
        Sleep(500);
    }

    // signal and wait for all of the workers to finish
    KillWorker();

    // shut down the url manager
    urlManager.Stop();
}