42 #include <wx/dialog.h>
45 #include <wx/stattext.h>
46 #include <wx/button.h>
47 #include <wx/thread.h>
49 #include <wx/evtloop.h>
67 bool Create(wxWindow* parent);
72 void OnTimer(wxTimerEvent& event);
119 catch (
const std::exception&) {
149 class CAsyncCallEventLoop :
public wxGUIEventLoop
152 CAsyncCallEventLoop(
int JobId) : m_JobId(JobId), m_TopWnd() {}
154 wxWindow* GetTopWnd() {
return m_TopWnd; }
164 wxEventLoopActivator activate(
this);
168 wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
170 wxTopLevelWindow* win =
dynamic_cast<wxTopLevelWindow*
>(node->GetData());
171 if (win && win->IsActive()) {
175 node = node->GetNext();
196 if( !::wxIsMainThread() ){
213 for(
unsigned long misec = 0; misec < 1000; misec=misec*2+1 ){
214 ::wxMilliSleep( misec );
224 CAsyncCallEventLoop loop(
m_JobId);
253 : m_Call(call), m_JobId(jobId), m_Timer(this), m_ProgressInd(), m_CancelBtn()
261 parent = GetParentForModalDialog(parent, style);
263 wxDialog::Create(parent,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, style);
264 SetBackgroundColour(wxColor(
wxT(
"#FFE793")));
271 GetSizer()->SetSizeHints(
this);
276 wxRect parentRect = parent->GetScreenRect();
278 Move(parentRect.GetRight() - rect.GetWidth() - 2, parentRect.GetBottom() - rect.GetHeight() - 2);
286 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
287 itemDialog1->SetSizer(itemBoxSizer1,
true);
289 wxFont bold(wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), wxNORMAL_FONT->GetStyle(), wxFONTWEIGHT_BOLD, wxNORMAL_FONT->GetUnderlined(), wxNORMAL_FONT->GetFaceName());
290 itemStaticText3->SetFont(bold);
291 itemStaticText3->SetForegroundColour(*wxBLACK);
292 itemBoxSizer1->Add(itemStaticText3, 0, wxALIGN_LEFT|wxTOP|wxLEFT|wxRIGHT, 5);
294 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxHORIZONTAL);
295 itemBoxSizer1->Add(itemBoxSizer2);
298 itemBoxSizer2->Add(
m_ProgressInd, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
301 itemBoxSizer2->Add(
m_CancelBtn, 0, wxALIGN_LEFT | wxALL, 5);
312 wxPoint posOld = GetPosition() + GetSize();
323 Move(posOld - GetSize());
330 EndModal(wxID_CANCEL);
static bool fInsideAsyncCall
bool GUI_AsyncExecUnit(IExecuteUnit &exec_unit, const wxString &msg)
void GUI_AsyncJoinFuture(const job_future_base &future, const string &msg)
std::invoke_result< _Fty, ICanceled & >::type GUI_AsyncExec(_Fty &&_Fnarg, const wxString &msg=wxT("Accessing network..."))
CAsyncCall::Call & m_Call
bool Create(wxWindow *parent)
CIndProgressBar * m_ProgressInd
void OnTimer(wxTimerEvent &event)
CAsyncCallDlg(wxWindow *parent, CAsyncCall::Call &call, int jobId)
void OnCancelClick(wxCommandEvent &event)
virtual bool IsCanceled() const
wxString GetDescr() const
bool IsCancalable() const
Class for GUI asyncronous execition.
static bool InsideAsyncCall()
CExecJob(CAsyncCall::Call *call)
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
virtual CConstIRef< IAppJobError > GetError()
Returns IAppJobError object describing internal error that caused the Job to fail.
std::exception_ptr m_Exception
virtual CRef< CObject > GetResult()
Returns the Job Result.
CAsyncCall::Call * m_Call
virtual bool IsCanceled() const
virtual string GetDescr() const
Returns a human readable description of the Job (optional)
virtual void RequestCancel()
RequestCancel() is called to notify the Job that it shall exit Run() function ASAP.
virtual CConstIRef< IAppJobProgress > GetProgress()
return progress object, the function shall be synchronized internally.
Interface for testing cancellation request in a long lasting operation.
virtual bool Execute(ICanceled &canceled)=0
Include a standard set of the NCBI C++ Toolkit most basic headers.
static CAppJobDispatcher & GetInstance()
bool DeleteJob(TJobID job_id)
when a Job is deleted the listener is not notified
EJobState
Job states (describe FSM)
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
TJobState GetJobState(TJobID job_id)
All Get() functions return values stored in the Registy not the actual.
void CancelJob(TJobID job_id)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void Run(void)
Enter the main loop.
const struct ncbi::grid::netcache::search::fields::SIZE size
wxRect GetScreenRect(const wxWindow &win)