예제 #1
0
void wxApp::WakeUpIdle()
{
    // Send the top window a dummy message so idle handler processing will
    // start up again.  Doing it this way ensures that the idle handler
    // wakes up in the right thread (see also wxWakeUpMainThread() which does
    // the same for the main app thread only)
    wxWindow * const topWindow = wxTheApp->GetTopWindow();
    if ( topWindow )
    {
        HWND hwndTop = GetHwndOf(topWindow);

        // Do not post WM_NULL if there's already a pending WM_NULL to avoid
        // overflowing the message queue.
        //
        // Notice that due to a limitation of PeekMessage() API (which handles
        // 0,0 range specially), we have to check the range from 0-1 instead.
        // This still makes it possible to overflow the queue with WM_NULLs by
        // interspersing the calles to WakeUpIdle() with windows creation but
        // it should be rather hard to do it accidentally.
        MSG msg;
        if ( !::PeekMessage(&msg, hwndTop, 0, 1, PM_NOREMOVE) ||
              ::PeekMessage(&msg, hwndTop, 1, 1, PM_NOREMOVE) )
        {
            if ( !::PostMessage(hwndTop, WM_NULL, 0, 0) )
            {
                // should never happen
                wxLogLastError(wxT("PostMessage(WM_NULL)"));
            }
        }
    }
#if wxUSE_THREADS
    else
        wxWakeUpMainThread();
#endif // wxUSE_THREADS
}
예제 #2
0
void wxMutexGuiLeaveImpl()
{
    wxCriticalSectionLocker enter(*gs_critsectWaitingForGui);

    if ( wxThread::IsMain() )
    {
        gs_bGuiOwnedByMainThread = false;
    }
    else
    {
        // decrement the number of threads waiting for GUI access now
        wxASSERT_MSG( gs_nWaitingForGui > 0,
                      wxT("calling wxMutexGuiLeave() without entering it first?") );

        gs_nWaitingForGui--;

        wxWakeUpMainThread();
    }

    gs_critsectGui->Leave();
}
예제 #3
0
void wxMutexGuiEnterImpl()
{
    // this would dead lock everything...
    wxASSERT_MSG( !wxThread::IsMain(),
                  wxT("main thread doesn't want to block in wxMutexGuiEnter()!") );

    // the order in which we enter the critical sections here is crucial!!

    // set the flag telling to the main thread that we want to do some GUI
    {
        wxCriticalSectionLocker enter(*gs_critsectWaitingForGui);

        gs_nWaitingForGui++;
    }

    wxWakeUpMainThread();

    // now we may block here because the main thread will soon let us in
    // (during the next iteration of OnIdle())
    gs_critsectGui->Enter();
}
예제 #4
0
void wxApp::WakeUpIdle()
{
    // Send the top window a dummy message so idle handler processing will
    // start up again.  Doing it this way ensures that the idle handler
    // wakes up in the right thread (see also wxWakeUpMainThread() which does
    // the same for the main app thread only)
    wxWindow * const topWindow = wxTheApp->GetTopWindow();
    if ( topWindow )
    {
        HWND hwndTop = GetHwndOf(topWindow);

        // Do not post WM_NULL if there's already a pending WM_NULL to avoid
        // overflowing the message queue.
        //
        // Notice that due to a limitation of PeekMessage() API (which handles
        // 0,0 range specially), we have to check the range from 0-1 instead.
        // This still makes it possible to overflow the queue with WM_NULLs by
        // interspersing the calles to WakeUpIdle() with windows creation but
        // it should be rather hard to do it accidentally.
        MSG msg;
        if ( !::PeekMessage(&msg, hwndTop, 0, 1, PM_NOREMOVE) ||
              ::PeekMessage(&msg, hwndTop, 1, 1, PM_NOREMOVE) )
        {
            // If this fails too, there is really not much we can do, but then
            // neither do we need to, as it normally indicates that the window
            // queue is full to the brim with the messages and so the main loop
            // is running and doesn't need to be woken up.
            //
            // Notice that we especially should not try use wxLogLastError()
            // here as this would lead to another call to wxWakeUpIdle() from
            // inside wxLog and stack overflow due to the resulting recursion.
            ::PostMessage(hwndTop, WM_NULL, 0, 0);
        }
    }
#if wxUSE_THREADS
    else
        wxWakeUpMainThread();
#endif // wxUSE_THREADS
}
예제 #5
0
파일: evtloop.cpp 프로젝트: jonntd/dynamica
void wxConsoleEventLoop::WakeUp()
{
#if wxUSE_THREADS
    wxWakeUpMainThread();
#endif
}