ScriptingOnEvent Method (ScriptingEventsList, FuncScriptEventArgs, Task, CancellationToken) |
Creates an adhoc event binding to act on.
Namespace:
RRAutoLib.Scripting
Assembly:
RRAutoLib (in RRAutoLib.dll) Version: 4.0.8678.28884
Syntax
RemarksThis method was designed specifically for use within the scripting context and is only safe to be called on the CTC thread.
Examples
In the following example, execution will halt until either of the two bound sensors report an
On state.
e2.Sender returns the first object that raised the event (in this example, one of the two bound sensors).
Setting
e2.Dispose, in the function unbinds the events and completes the task this method returns.
The function could optionally be left out in which case the task completes immediately when either event occurs.
Optionally the
e.CancelToken passed from the hosting script object, can be handed down to this method so it can participate
in a cancellation order received from the parent script. Note that although both
e. and
e2. are
ScriptEventArgs, they are given
different names to disambiguate the upstream event argument from the downstream one.
Await OnEvent(New EventsList() From {
{CtcSensor("Sensor1"), "StateReported"},
{CtcSensor("Sensor2"), "StateReported"}},
Function(e2 as ScriptEventArgs)
If e2.Sender.State = 1 Then e2.Dispose()
End Function,
e.CancelToken)
See Also