Main Content

setApplicationStateCallback

Trigger a function when state of application changes

Since R2022b

    Description

    setApplicationStateCallback(callback) calls the function provided in callback when the state of the specified application gets changed.

    example

    Examples

    collapse all

    Display the state transition for an application using the following function where appName is the name of the application, appState is the state of the application, and actionStatus is the status of an action performed on the application.

    function applicationStateCallback(appName, appState, actionStatus)
    if actionStatus
       switch appState
          case linux.AppState.IDLE
              disp(['application '  appName ' has moved to idle state.']);
          case linux.AppState.RUNNING
              disp(['application '  appName ' has moved to running state.']);
          case linux.AppState.SUSPENDED
              disp(['application '  appName ' has moved to suspended state.']);
       end
    else 
       disp(['Action performed on application ' appName ' has failed']); 
    end
    end
    tg.setApplicationStateCallback(@applicationStateCallback);

    Input Arguments

    collapse all

    Provide a function with required action to occur when state of the application gets changed. A callback is expected to have 3 input arguments specifying application name, application state, and status of an action performed on the application.

    Version History

    Introduced in R2022b