RunGlobalProcedureAsyncGetStatus

This function gets the status of one or more global procedures that were run asynchronously by calling the RunGlobalProcedureAsync function. Each procedure is run in its own thread, so that it does not slow down or interfere with other threads.

Function Group Execution Windows Embedded Thin Client Mobile Access
RunGlobalProcedureAsyncGetStatus Module Activity Synchronous Supported Supported Not supported; see note Not supported

Syntax

Web Studio Help obalprocedureasyncgetstatus.xml d159421e97 RunGlobalProcedureAsyncGetStatus
  RunGlobalProcedureAsyncGetStatus( )  RunGlobalProcedureAsyncGetStatus( optNumThreadID )  RunGlobalProcedureAsyncGetStatus( "optTagThreadIDs", "optTagStatus", "optTagParameters" )  
optNumThreadID
The thread ID returned by the RunGlobalProcedureAsync function, if the procedure was successfully executed.
optTagThreadIDs
The name of an Array tag that will receive the thread IDs of all currently running and recently completed threads.
Note: The tag name should be enclosed in quotes, as shown in the syntax diagram, or else the function will try to use the value of the tag.
optTagStatus
The name of an Array tag that will receive the statuses of all currently running and recently completed threads.
Note: The tag name should be enclosed in quotes, as shown in the syntax diagram, or else the function will try to use the value of the tag.
optTagParameters
The name of an Array tag that will receive the parameters of all currently running and recently completed threads.
Note: The tag name should be enclosed in quotes, as shown in the syntax diagram, or else the function will try to use the value of the tag.

Returned value

If the function succeeds, then the possible returned values depend on how the function was called:
  • If the function was called with no parameters…
      RunGlobalProcedureAsyncGetStatus( )  

    …then the returned value is the total number of threads that are currently running.

  • If the function was called with only the optNumThreadID parameter…
      RunGlobalProcedureAsyncGetStatus( optNumThreadID )  

    …then the returned value is either 0, indicating that the thread is still running, or the value that was returned by the procedure.

  • If the function was called with the Array tags…
      RunGlobalProcedureAsyncGetStatus( "optTagThreadIDs", "optTagStatus", "optTagParameters" )  

    …then the tags will receive the appropriate values for all currently running and recently completed threads.

If the function fails, then it returns one of the following errors:
Value Description
-1 Function is not supported on Viewer / Web Thin Client.
-2 Invalid thread ID.
-3 Invalid optTagThreadIDs.
-4 Invalid optTagStatus.
-5 Invalid optTagParameters.
-100 Internal error. Please contact technical support.

Notes

It is very important to note that this function can only be called by background tasks (e.g., Math, Script, Scheduler) on the project server. It cannot be directly called from any project client, even if the project client is running on the same workstation or device as the project server, because the client process is single-threaded. To indirectly call the function from a project client, configure a Math or Script worksheet to execute on a tag/expression trigger, and then configure a project screen to activate the trigger when needed. For example, configure the worksheet to execute when the value of MyTag is 1, and then configure a Button screen object to toggle the value of MyTag when pressed.

Also, when the call to RunGlobalProcedureAsync succeeds, it returns an ID for the thread created and starts running the procedure in that thread. The status of the thread is stored in an internal buffer and can be retrieved using the RunGlobalProcedureAsyncGetStatus function. The buffer gets cleared when:
  • The RunGlobalProcedureAsyncGetStatus function has been called and the thread status is different from 0 (thread is running); or
  • The maximum buffer size has been exceeded, the thread is no longer running, and a call to start a new thread has been made.

RunGlobalProcedureAsyncGetStatus