コード例 #1
0
ファイル: evtloopcmn.cpp プロジェクト: FuTingyan/wxWidgets
bool wxEventLoopBase::YieldFor(long eventsToProcess)
{
#if wxUSE_THREADS
    if ( !wxThread::IsMain() )
    {
        // Don't ever dispatch events from non-main threads.
        return false;
    }
#endif // wxUSE_THREADS

    // set the flag and don't forget to reset it before returning
    m_isInsideYield = true;
    m_eventsToProcessInsideYield = eventsToProcess;

    wxON_BLOCK_EXIT_SET(m_isInsideYield, false);

#if wxUSE_LOG
    // disable log flushing from here because a call to wxYield() shouldn't
    // normally result in message boxes popping up &c
    wxLog::Suspend();

    // ensure the logs will be flashed again when we exit
    wxON_BLOCK_EXIT0(wxLog::Resume);
#endif

    DoYieldFor(eventsToProcess);

    return true;
}
コード例 #2
0
ファイル: evtloopcmn.cpp プロジェクト: 3v1n0/wxWidgets
bool wxEventLoopBase::YieldFor(long eventsToProcess)
{
#if wxUSE_THREADS
    if ( !wxThread::IsMain() )
    {
        // Don't ever dispatch events from non-main threads.
        return false;
    }
#endif // wxUSE_THREADS

    // set the flag and don't forget to reset it before returning
    const int yieldLevelOld = m_yieldLevel;
    const long eventsToProcessOld = m_eventsToProcessInsideYield;

    m_yieldLevel++;
    wxON_BLOCK_EXIT_SET(m_yieldLevel, yieldLevelOld);

    m_eventsToProcessInsideYield = eventsToProcess;
    wxON_BLOCK_EXIT_SET(m_eventsToProcessInsideYield, eventsToProcessOld);

#if wxUSE_LOG
    // disable log flushing from here because a call to wxYield() shouldn't
    // normally result in message boxes popping up &c
    wxLog::Suspend();

    // ensure the logs will be flashed again when we exit
    wxON_BLOCK_EXIT0(wxLog::Resume);
#endif

    DoYieldFor(eventsToProcess);

#if wxUSE_EXCEPTIONS
    // If any handlers called from inside DoYieldFor() threw exceptions, they
    // may have been stored for later rethrow as it's unsafe to let them escape
    // from inside DoYieldFor() itself, as it calls native functions through
    // which the exceptions can't propagate. But now that we're back to our own
    // code, we may rethrow them.
    if ( wxTheApp )
        wxTheApp->RethrowStoredException();
#endif // wxUSE_EXCEPTIONS

    return true;
}