Click or drag to resize

ListAPIClearPendingEvents Method

Clears all pending Events (e.g. 'ListIdle', 'ListDone', 'Aborted', 'Progress', etc. ) from the internal EventQueue.

Namespace: RAYLASE.SPICE3.ClientLib
Assembly: RAYLASE.SPICE3.ClientLib (in RAYLASE.SPICE3.ClientLib.dll) Version: 3.4.1
Syntax
C#
public void ClearPendingEvents()
Remarks

An Abort, which can be due to either the hardware Abort-Signal, or an explicit call of AbortExecution, and which may be completely asynchronous to any list executions, causes an Aborted Event to be placed in the EventQueue.

It normally remains in the EventQueue only until it is retrieved by one of the WaitForXXX() methods (see below).

However, if the Abort, or, indeed, any other kind of Event, occurs when no WaitForXXX() is active, it will remain pending in the EventQueue.

Applications can use ClearPendingEvents in order to ensure that any pending Events will not be mis-interpreted by subsequent calls of a WaitForXXX() method.

Example
ClearPendingEVents Example
using ( ClientAPI client = new ClientAPI() )
{
    client.Connect( CardIP );
    client.System.ResetToDefaults();

    // For this example, we assume that we already have
    // a suitable definition for the contents of the list.
    CommandList list = CommandList.FromString( listContents );

    // Furthermore, we simply assume here that 2000ms is a suitable timeout value.
    int timeoutMs = 2000;

    client.Laser.ArmLaser( true );

    int listID = 0;

    // For this example, we are assuming that the Abort-Signal may be used
    // to stop execution of the current list, but that we want to carry on
    // executing subsequent lists.
    for ( int loopCounter = 0; loopCounter < maxLoopCount; loopCounter++ )
    {
        client.List.Set( listID, list );

        // Make sure there are no events still pending from previous list executions.
        client.List.ClearPendingEvents();

        client.List.Execute( listID );

        try
        {
            int? doneID;
            client.List.WaitForListDone( out doneID, timeoutMs );
            if ( doneID != listID )
            {
                throw new ListException( "Got ListDone for wrong listID!" );
            }
        }
        catch ( RpcRemoteException ex ) when ( ex.InnerException is AbortedException )
        {
            Console.WriteLine( $"WaitForListDone got: {ex.InnerException} " );
        }
        finally
        {
            client.List.Delete( listID );
        }
    }
}
See Also