Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ XtWorkProc(3) — OSF1 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtAppAddWorkProc(1)

XtRemoveWorkProc(1)

 

Name

XtWorkProc — prototype procedure for performing background processing. 

Synopsis

typedef Boolean (∗XtWorkProc)(XtPointer);

    XtPointer client_data;

Arguments

client_data
Represents the client data specified when the work procedure was registered.

Description

A work procedure is an application-supplied function that is executed while an application is idle waiting for an event.  Work procedures are registered with XtAppAddWorkProc.  They can perform any calculation that is short enough that the routine will return in a small fraction of a second.  If the work procedure is too long, the user’s response time will suffer. 

If a work procedure returns True, then Xt will remove it and it will not be called again.  But if one returns False, it will be called repeatedly every time there is idle time, until the application calls XtRemoveWorkProc.  A work procedure would return True if it performs a one-time setup such as creating a pop-up widget.  It would return False if it were continuously updating a disk file as security against a system crash or server connection failure. 

You can register multiple work procedures, and they will be performed one at a time.  The most recent work procedure added has the highest priority.  Therefore, for example, if you want to create ten pop-up widgets during idle time, you should add ten work procedures.  The pop up that you expect to need first should be added in the last work procedure registered. 

Examples

The example below shows a work procedure to create a pop-up widget. 

/∗ work procedure ∗/
Boolean
create_popup(client_data)
XtPointer client_data;
{
    Widget parent = (Widget) client_data;
    Widget dialog, dialogDone;
     pshell = XtCreatePopupShell( "pshell", transientShellWidgetClass,
        parent, NULL, 0);
     dialog = XtCreateManagedWidget( "dialog", dialogWidgetClass,
        pshell, NULL, 0);
     dialogDone = XtCreateManagedWidget( "dialogDone", commandWidgetClass,
        dialog, NULL, 0);
     XtAddCallback(dialogDone, XtNcallback, DialogDone, dialog);
     return(True);   /∗ makes Xt remove this work proc automatically ∗/
}

Remember that Xt cannot interrupt a work procedure while it is running; the procedure must voluntarily give up control by returning, and it must do so quickly to avoid slowing user response. 

See Also

XtAppAddWorkProc(1), XtRemoveWorkProc(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026