Runtime.WaitForMultipleSignals

Prototypes

static int WaitForMultipleSignals( Matrix mNames <, boolean bWaitForAll <, int nPollingDelay >> )

static int WaitForMultipleSignals( String[] asNames <, boolean bWaitForAll <, int nPollingDelay >> )

Return Value

If bWaitForAll is true, the return value is -1.

If bWaitForAll is false and the mNames matrix is undefined (or the asNames array is empty), the return value is -1.

Otherwise, the return value is the one-based index of the signal in mNames (or asNames) that is set. Note that the return value is a one-based index even if the method is called with a String[] parameter. In this case, you must subtract one from the return value before indexing into the asNames array because Java arrays use zero-based indexing.

Parameters

Matrix mNames
A character vector containing the names of the signals to wait for. The vector can contain at most 60 elements.

String[] asNames
An array containing the names of the signals to wait for. The array can contain at most 60 elements.

boolean bWaitForAll
If bWaitForAll is true, the method returns when all the signals in mNames (or asNames) are set. If bWaitForAll is false, the method returns when any of the signals in mNames (or asNames) is set. Calling this method without specifying the bWaitForAll parameter is equivalent to calling it with bWaitForAll equal to true.

int nPollingDelay
An integer in the range 0-1000 specifying the number of milliseconds to delay after polling the signals. You should very rarely need to use this parameter. If nPollingDelay is 0, the method does not delay after polling the signals. This consumes a significant amount of CPU time. If nPollingDelay is 1000, the method waits one second after polling the signals. Calling this method without specifying the nPollingDelay parameter is equivalent to calling it with nPollingDelay equal to 200. The nPollingDelay parameter is ignored if bWaitForAll is true.

Remarks

This method waits for signals to be set by other IMLPlus programs.

A signal enables an IMLPlus program to communicate the occurrence of a significant event to another IMLPlus program. A signal is created on-demand when its name is used with one of the Signal methods. A signal is always in one of two states: Set, or Clear. All signals are created in the Clear state. To configure a signal to the Set state, call the method Runtime.SetSignal. To configure a signal to the Clear state, call the method Runtime.ClearSignal. To halt further program execution until a signal is set, call the method Runtime.WaitForSignal. To halt further program execution until multiple signals are set, call the method Runtime.WaitForMultipleSignals.

Example
run GetPersonalFilesDirectory( Path );
Path = Path + "Programs/";

NumSubPrograms = 2;

do k = 1 to NumSubPrograms;
    Signal = strip(putn(k,"z3."));
    SubProgramFileName = "SubProgram" + Signal + ".sx";
    PathName = Path + SubProgramFileName;
    ProgramText = { "Runtime.Delay( 3000 );",
                    "Runtime.SetSignal( '&Signal' );" };
    ProgramText = tranwrd( ProgramText, "&Signal", Signal );
    Runtime.WriteProgramFile( PathName, ProgramText );
    Runtime.ClearSignal( Signal );
    Runtime.RunProgramFile( PathName, "", false, true, 1 );
    Signals = Signals // Signal;
    SubProgramFileNames = SubProgramFileNames // SubProgramFileName;
end;

do while ( nrow(Signals) > 0 );
    k = Runtime.WaitForMultipleSignals( Signals, false );
    print (strip(SubProgramFileNames[k]) + " finished");
    Signals = remove( Signals, 1 );
    SubProgramFileNames = remove( SubProgramFileNames, 1 );
end;
See Also

Runtime.ClearSignal

Runtime.SetSignal

Runtime.WaitForSignal