44 #define TASK_CATCH_AND_REPORT(message, task) \
45 catch (CException& e) { \
46 ERR_POST(message << task.GetDescr()); \
47 ERR_POST(e.ReportAll()); \
48 } catch (std::exception& ee) { \
49 ERR_POST(message << task.GetDescr() << ee.what()); \
59 m_DisplayDelay(display_delay)
65 "CAppTask - unexpected exception while executing a child task.";
156 static string sInvalid =
"Invalid";
157 static string sInitial =
"Initial";
158 static string sBackgrounded =
"Running";
159 static string sCompleted =
"Completed";
160 static string sFailed =
"Failed";
161 static string sCanceled =
"Canceled";
169 return sBackgrounded;
177 return "Unknown State";
215 r_task->SetListener(
this);
221 r_task->SetListener(
NULL);
230 r_task->SetListener(
NULL);
235 r_task->SetListener(
NULL);
267 task->SetListener(
NULL);
270 task->CancelBackgrounded();
#define TASK_CATCH_AND_REPORT(message, task)
ON_EVENT_RANGE(CAppTaskServiceEvent, CAppTaskServiceEvent::eWakeUpSignal, CAppTaskServiceEvent::eTaskCanceled, &CCompositeAppTask::OnTaskEvent) CCompositeAppTask
CCompositeAppTask.
static const char * kChildFailed
CAppTask - default implementation of IAppTask, use it as a base class for custom tasks.
int m_DisplayDelay
tasks display delay
virtual void SetListener(CEventHandler *handler)
set a Listener; this allows a taks running in background to notify the Listener (usually Task Manager...
virtual IEventLogAction * CreateEventLogAction()
returns an action for activating task results (optional, can return NULL)
virtual bool IsVisible()
returns true if the task should be visible in UI visible task shall represent operations understood b...
virtual ETaskState Run()
execute the task, this function is called on the main UI thread if a task needs to execute in backgro...
virtual ETaskState GetState()
returns the current task state
static string StateToString(ETaskState state)
CAppTask(const string &descr=kEmptyStr, bool visible=true, int display_delay=0)
CAppTask.
virtual bool x_IsFiniteState()
CEventHandler * m_Listener
virtual void OnCancel()
this will be called on pending tasks that will be removed from the queue and won't get a chance to ru...
virtual string GetDescr() const
returns a human-readable description of the Task (optional)
virtual ETaskState x_Run()
override this function in derived classes
const bool m_Visible
indicates whether the task is visible
virtual void CancelBackgrounded()
make a request to cancel backgrounded task (not called for foreground tasks)
virtual string GetStatusText() const
returns human-readable text describing the current task state
string m_Descr
task description
int GetStatusDisplayDelay()
returns delay in seconds used for certain fast (and not very important tasks) to only show its status...
CCompositeAppTask - an application task that consists of subtasks.
void OnTaskEvent(CEvent *event)
virtual TTaskRef x_NextSubTask()=0
prepares the next subtask (makes it current), this function is used for iterating subtasks.
virtual ETaskState x_RunCurrentSubTask()
runs the current subtask; one may override this function in order to perform special pre-execution or...
virtual void CancelBackgrounded()
make a request to cancel backgrounded task (not called for foreground tasks)
virtual ETaskState Run()
execute the task, this function is called on the main UI thread if a task needs to execute in backgro...
virtual TTaskRef x_GetCurrentSubTask()=0
returns a references to the current subtask
CEvent - generic event implementation TODO TODO - Attachments.
ETaskState
List of task states defining the task management FSM.
CIRef< IAppTask > GetTask()
@ eCanceled
canceled by Task Manager
@ eBackgrounded
task is executing in background
@ eFailed
failed during execution
@ eCompleted
successfully finished
@ eInitial
has not been executed yet
@ eRunning
task is executing on the main UI thread
const TEventID GetID(void) const
Inline Implementation.
void Post(CRef< CEvent > evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Handles an event asynchronously (process and/or dispatch).
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.