FireEvent Example (Visual J++)

   

This example shows what a call to FireEvent looks like. Refer to ISystemDebugEventFire Example (Visual J++) to see the constant declarations and object creation code, as well as to see this code in a form you can run with minor modifications.

// Prepare to generate an event.
// Declare an array to hold event parameters
private static final int MAXPARAMS = 2;

// Event data is passed in arrays of parameter names (keys) and values.
private static void SampleFireEvent()
   {
      SafeArray saKeys = new SafeArray( Variant.VariantString, MAXPARAMS
);
      saKeys.setString( 0, "CorrelationID" );         // Stock parameter
      saKeys.setString( 1, "This is a custom parameter" );
      Variant rgKeys = new Variant( saKeys, false );
      
      SafeArray saValues = new SafeArray( Variant.VariantString,
MAXPARAMS );
      saValues.setString( 0, "String parameter" );
      saValues.setString( 1, "Another string parameter" );
      Variant rgValues = new Variant( saValues, false );
      
      // Generate the event.
      // SAMPLE_EVENT_GUID is the GUID of the registered event to
      // generate
      m_IEA.FireEvent( SAMPLE_EVENT_GUID, rgKeys, rgValues, MAXPARAMS, 
         eVSAEventFlags.cVSAEventDefaultSource |
eVSAEventFlags.cVSAEventDefaultTarget );
   }