Routines (alphabetical) > Object Classes > Miscellaneous Object Classes > IDL_IDLBridge::OnCallback

# IDL_IDLBridge::OnCallback

Syntax | Arguments | Keywords | Examples | Version History

The IDL_IDLBridge::OnCallback procedure method is called automatically when an asynchronous command ends. By default the IDL_IDLBridge::OnCallback method will check if the CALLBACK property has been set, and if so, the method will automatically call the procedure indicated by the CALLBACK property.

If you are using a subclass of IDL_IDLBridge, you may want to override the IDL_IDLBridge::OnCallback method to provide your own functionality.

Note: This method is only called when executing an asynchronous command (when the NOWAIT keyword has been set).

When the asynchronous command is completed, aborted, or halted due to an error, the child IDL process calls back into the main IDL process. The main IDL process puts a callback event into the callback event queue for the bridge object. The callback queue for this bridge object is flushed (and the CALLBACK procedure or OnCallback method is called) when one of the following occurs:

- The widget event queue is flushed by IDL’s widget event processing
- The user calls WIDGET_EVENT
- The user calls any IDL_IDLBridge method (except Abort)
- The user calls OBJ_DESTROY

## Syntax

Obj->[IDL_IDLBridge::]OnCallback, Status, Error

## Arguments

### Status

The Status argument will be set to one of the integer values from the following table:

Value | Description |
2 | Completed command | Empty string
3 | Error halted execution | Descriptive error string
4 | Aborted execution | Abort message

Note: Because the OnCallback method is only called when a command ends, values of Status=0 (Idle) or Status=1 (Executing) will never be returned. (See IDL_IDLBridge::Status for a list of all possible status values.)

### Error

The Error argument will be set to a string corresponding to any error that may have occurred while executing the command in the slave process. As shown in the table above, if Status contains an error status (3), the Error argument returns a descriptive error string. If Status indicates an aborted status (4), Error returns an abort message. Otherwise, the Error argument will be set to an empty string.

## Keywords

None.

## Examples

Although this method does not use the OnCallback method directly, setting the IDL_IDLBridge CALLBACK property causes this method to automatically initiate your callback procedure. The following example shows how to define a simple callback procedure.

1. Create a program file that contains the following code. This is the callback procedure:

   PRO idl_idlbridge_example_callback, status, error, $

   oBridge, userdata

   ; Get the result of the FFT command from the child

   ; process and print min and max values.

   result = oBridge->GetVar('result')

   PRINT, 'FFT finished'

   PRINT, MIN(result), MAX(result)

   OBJ_DESTROY, oBridge

   END

2. Enter all of the following lines at the command prompt. When the FFT command is complete, the specified callback procedure will be automatically called.

   oBridge = Obj_New('IDL_IDLBridge', $

   CALLBACK='idl_idlbridge_example_callback')

   ; Compute a very long FFT.

   oBridge->Execute, 'result = FFT(Randomu(1,1729,1729))', $

   /NOWAIT

   ; Our program keeps going while the FFT is being computed.

   Print, 'IDL command line is still active.'

Note: Also see the IDL_IDLBridge Examples , which provide additional callback procedure samples.

## Version History

6.3 | Introduced