本文整理汇总了C++中CBOINCBaseFrame::AddPendingEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CBOINCBaseFrame::AddPendingEvent方法的具体用法?C++ CBOINCBaseFrame::AddPendingEvent怎么用?C++ CBOINCBaseFrame::AddPendingEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBOINCBaseFrame
的用法示例。
在下文中一共展示了CBOINCBaseFrame::AddPendingEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RequestRPC
//.........这里部分代码省略.........
// process events so user can maximize the manager.
//
// NOTE: CBOINCGUIApp::FilterEvent() discards those events
// which might cause posting of more RPC requests while
// we are in this loop, to prevent undesirable recursion.
// Since the manager is minimized, we don't have to worry about
// discarding crucial drawing or command events.
// The filter does allow the the Open Manager menu item from
// the system tray icon and wxEVT_RPC_FINISHED event.
//
timeToSleep = DELAY_WHEN_MINIMIZED; // Allow user to maximize Manager
wxSafeYield(NULL, true);
}
// OnRPCComplete() clears m_bWaitingForRPC if RPC completed
if (! m_bWaitingForRPC) {
return retval;
}
mutexErr = m_pRPC_Request_Mutex->Lock();
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
// Simulate handling of CRPCFinishedEvent but don't allow any other
// events (so no user activity) to prevent undesirable recursion.
// Since we don't need to filter and discard events, they remain on
// the queue until it is safe to process them.
// Allow RPC thread to run while we wait for it.
if (!current_rpc_request.isActive) {
mutexErr = m_pRPC_Request_Mutex->Unlock();
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
HandleCompletedRPC();
continue;
}
// Wait for RPC thread to wake us
// This does the following:
// (1) Unlocks the Mutex and puts the main thread to sleep as an atomic operation.
// (2) On Signal from RPC thread: locks Mutex again and wakes the main thread.
m_pRPC_Request_Condition->WaitTimeout(timeToSleep);
mutexErr = m_pRPC_Request_Mutex->Unlock();
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
}
// Demand RPC has taken longer than RPC_WAIT_DLG_DELAY seconds and
// Manager is not minimized, so display the "Please Wait" dialog
// with a Cancel button. If the RPC does complete while the dialog
// is up, HandleCompletedRPC() will call EndModal with wxID_OK.
//
// NOTE: the Modal dialog permits processing of all events, but
// CBOINCGUIApp::FilterEvent() blocks those events which might cause
// posting of more RPC requests while in this dialog, to prevent
// undesirable recursion.
//
if (m_RPCWaitDlg) {
response = m_RPCWaitDlg->ShowModal();
// Remember time the dialog was closed for use by RunPeriodicRPCs()
m_dtLasAsyncRPCDlgTime = wxDateTime::Now();
if (response != wxID_OK) {
// TODO: If user presses Cancel in Please Wait dialog but request
// has not yet been started, should we just remove it from queue?
// If we make that change, should we also add a separate menu item
// to reset the RPC connection (or does one already exist)?
retval = -1;
// If the RPC continues to get data after we return to
// our caller, it may try to write into a buffer or struct
// which the caller has already deleted. To prevent this,
// we close the socket (disconnect) and kill the RPC thread.
// This is ugly but necessary. We must then reconnect and
// start a new RPC thread.
if (current_rpc_request.isActive) {
current_rpc_request.isActive = false;
rpcClient.close();
RPC_requests.clear();
current_rpc_request.clear();
m_bNeedRefresh = false;
m_bNeedTaskBarRefresh = false;
// We will be reconnected to the same client (if possible) by
// CBOINCDialUpManager::OnPoll() and CNetworkConnection::Poll().
m_pNetworkConnection->SetStateDisconnected();
}
if (response == wxID_EXIT) {
pFrame = wxGetApp().GetFrame();
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT);
s_bSkipExitConfirmation = true;
pFrame->AddPendingEvent(evt);
}
}
if (m_RPCWaitDlg) {
m_RPCWaitDlg->Destroy();
}
m_RPCWaitDlg = NULL;
m_bWaitingForRPC = false;
}
}
return retval;
}