# SoftEvents

In Designer, one or more SoftEvents (or other events) can be used as a Trigger for executing a Task. A SoftEvent can be made to fire by calling either of the following script methods.

Note: If the Trigger method is called at a rate faster than the Task execution time, the Task will Queue the Triggers and process them one after the other. However, be aware that if Triggering is continually faster (no break), then the Task will eventually run out of queue space. In this case, Trigger events will be ignored until the Task Queue is either cleared or the Task has processed the queued events.

Use the following Task Properties to control and/or monitor the queue:

int Task.QueueLength | Gets or sets a value indicating the maximum number of triggers allowed before the queue can no longer be added to.
long Task.QueuedTriggersCount | Reports the current count of queued triggers for the Task.
bool Task.IsQueueFull | Signals that the items in the event queue has reached QueueLength.
bool Task.QueueTriggers | QueueTriggers must be enabled in order for a Task to be Triggered (even when triggers are being processed faster than the rate at which the triggers are being generated). Cognex recommends you disable this property temporarily in the event you need to reset multiple tasks queues for the purposes of keeping them in synch.

Trigger(int)

The Trigger method takes an int parameter which is the Id of the SoftEvent to fire.

Note: There are 4 SoftEvents that can be used with their Ids being 0 - 3.
TriggerObject(int, object)

The TriggerObject method takes two parameters.

- The int parameter is the Id of the SoftEvent to fire.

- The object parameter is used to pass Data which can be read within a Task using either the Task's SoftEventData property or using a SoftEvent Data Block. See the topic SoftEvent Data for more information.