Click or drag to resize

ScriptingOnEvent Method (ScriptingEventsList, CancellationToken)

Creates an adhoc event binding to act on.

Namespace:  RRAutoLib.Scripting
Assembly:  RRAutoLib (in RRAutoLib.dll) Version: 4.0.8678.28884
Syntax
Public Shared Function OnEvent ( 
	objEvents As ScriptingEventsList,
	Optional sctCancelToken As CancellationToken = Nothing
) As Task

Parameters

objEvents
Type: RRAutoLib.ScriptingScriptingEventsList
One or more events to be observed.
sctCancelToken (Optional)
Type: System.ThreadingCancellationToken
Token provided by a controlling source to notify this method that it should cancel its execution.

Return Value

Type: Task
The Task that can be awaited, if execution must halt while the events are bound.
Remarks
This 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 buttons are activated (pressed). 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.
VB
Await OnEvent(New EventsList() From {
    {CtcButton("Button1"), "Activated"}, 
    {CtcButton("Button2"), "Activated"}},
    e.CancelToken)
See other overload, for a version of this method, that can additionally execute some script, when the events are raised.
See Also