Studio:AutoScript Events

From STRIDE Wiki
Revision as of 16:09, 21 August 2009 by Timd (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

WaitForEvent

Syntax

  ascript.WaitForEvent()

Return Value

The return value is an object popped off of the front of this script's event queue. The returned object can be any of the following types. Each returned type exposes both Type and Name properties so that a script can identify the object and take appropriate action.

Object
Type
Name
Function.Owner Object "FunctionOwner" Function Name
Function.User Object "FunctionUser" Function Name
Message.Owner Object "BroadcastMessageOwner"
"OneWayMessageOwner"
"OneWayResponseOwner"
"TwoWayMessageOwner"
Message Name
Message.User Object "BroadcastMessageOwner"
"OneWayMessageOwner"
"OneWayResponseOwner"
"TwoWayMessageOwner"
Message Name
Timer Object "Timer" Timer Name
Error Object
(see Remarks)
"Error" "Host Error"
"Target Error"
"System Error"

Remarks

  • WaitForEvent() is used to provide synchronization between a script and the STRIDE Runtime when asynchronous calls are made. The synchronization is accomplished by creating a event queue for each ascript instance (typically each script has a single ascript instance). Events are pushed onto the back of the queue by the runtime, and they are popped off of the front of the queue using WaitForEvent().
  • WaitForEvent() will block script execution until an event is available in the queue.
  • You can test whether one or more events are pending in the queue by checking the IsEventPending Property.
  • An Error object is returned under the following circumstances:
 
  • a prior CallNonBlocking() or CallBypassOverrideNonBlocking() on a user function has failed to complete
  • a prior call to SendCmd() or SendCmdBypassOverride() on a user message has failed to complete
  • a prior call to Return() on an owner function that was called asynchronously has failed to complete
  • a prior call to SendRsp() on an owner message that was called asynchronously has failed to complete
  • the configured WaitTimeoutPeriod has elapsed