XtAppAddWorkProc()XtAppAddWorkProc()XtAppAddWorkProc - register a procedure to be called when the event loop is
idle.Synopsis
XtWorkProcId XtAppAddWorkProc(app_context, proc, client_data)
XtAppContext app_context;
XtWorkProc proc;
XtPointer client_data;
Inputs
app_context
Specifies the application context.
proc Specifies the procedure that is to be called when the appli‐
cation is idle.
client_data
Specifies data to be passed to proc when it is called.
Returns
A handle of type XtWorkProcId that can be passed to XtRemoveWorkProc()
to unregister the work procedure.
DescriptionXtAddWorkProc() registers the procedure proc and the data client_data
to be called by XtAppNextEvent() or XtAppProcessEvent() when there are
no pending input events and it would otherwise block. Multiple work
procedures can be registered, and the most recently added one is always
the one that is called. However, if a work procedure itself adds
another work procedure, the newly added one has lower priority than the
current one.
A work procedure returns a Boolean. If it returns True, it will auto‐
matically be unregistered and will not be called again. If it returns
False it will be called the next time the application is idle. See
XtWorkProc(2) for more information.
UsageXtAppAddWorkProc() implements a limited form of background processing.
Most applications spend most of their time waiting for input; to do
useful work during this idle time, you can register a work procedure
that will run when the application is idle.
A work procedure must return quickly or the application will not be
able to promptly respond to user events. If a large task needs to be
done in the background, the work procedure should periodically save its
state and return False. Work procedures should not be used to do friv‐
olous work in the background. In a multi-tasking system, an idle
application should generally actually be idle, and not steal CPU time
from other processes.
A work procedure can be explicitly removed by calling XtRemove‐
WorkProc() with the XtWorkProcId returned by this function.
Structures
The XtWorkProcId type is defined as follows:
typedef unsigned long XtWorkProcId;
See AlsoXtAppNextEvent(1), XtAppProcessEvent(1), XtRemoveWorkProc(1),
XtWorkProc(2).
Xt - Event Handling XtAppAddWorkProc()