Retrieving a callback function

The mi_retrieve_callback() function returns a callback-function pointer (MI_CALLBACK_FUNC) when you pass in a callback handle (MI_CALLBACK_HANDLE). This function is useful when a DataBlade® API module needs to change temporarily the callback that is registered for a particular event.

To change a registered callback temporarily:

  1. Register the initial callback with mi_register_callback().

    The mi_register_callback() function returns a callback handle for the callback that it receives as its third argument.

  2. Perform tasks that require the event handling of the initial callback.
  3. Obtain the callback-function pointer for the initial callback with mi_retrieve_callback().

    Pass the callback handle for the initial callback as an argument to the mi_retrieve_callback() function. The function returns a callback-function pointer, which saves the location of the registered initial callback.

    The initial callback must be unregistered.

  4. Register the temporary callback with mi_register_callback().

    This call to mi_register_callback() overwrites the previous callback that was registered for the event and returns a callback handle for the temporary callback.

  5. Perform the tasks that require the event handling of the temporary callback.
  6. Restore the initial callback with mi_register_callback().

    Pass the saved callback-function pointer (step 3) of the initial callback as the third argument of mi_register_callback(). The function returns a new callback handle for the initial callback.