Packagecom.rosettastone.library.taskmanager
Classpublic class TaskWithClosure
InheritanceTaskWithClosure Inheritance Task Inheritance flash.events.EventDispatcher
Subclasses SynchronousTaskWithClosure

Task that invokes a specified function upon execution. The function invoked will retain the scope of where it was defined, allowing for easy access to other class/method variables. This type of Task can be asynchronous. It will not complete (or error) until specifically instructed to do so. This instruction should be triggered as a result of the custom function it executes.



Public Properties
 PropertyDefined By
  autoCompleteAfterRunningFunction : Boolean
If TRUE this Task will synchronously complete itself once it has invoked its custom run function.
TaskWithClosure
  customRunFunction : Function
Function to be executed when this Task is run
TaskWithClosure
 Inheriteddata : *
[read-only] Optional data parameter passed to the Task complete/error/interruption method.
Task
 Inheritedid : Number
[read-only]
Task
 Inheritedinterruptible : Boolean
[read-only] The current Task can be interrupted.
Task
 InheritedinterruptingTask : ITask
[read-only] The Task currently interrupting the composite Task's execution (or NULL if no such Task exists).
Task
 InheritedisComplete : Boolean
[read-only] The current task has successfully completed execution.
Task
 InheritedisErrored : Boolean
[read-only] The current task failed.
Task
 InheritedisInterrupted : Boolean
[read-only]
Task
 InheritedisRunning : Boolean
[read-only] The task is currently running.
Task
 Inheritedmessage : String
[read-only] Optional message parameter passed to the task complete/error/interruption method.
Task
 InheritednumInternalOperations : int
[read-only] Number of internal operations conducted by this task.
Task
 InheritednumInternalOperationsCompleted : int
[read-only] Number of internal operations that have completed.
Task
 InheritednumInternalOperationsPending : int
[read-only] Number of internal operations not yet completed.
Task
 InheritednumTimesCompleted : int
[read-only] Number of times this task has completed.
Task
 InheritednumTimesErrored : int
[read-only] Number of times this task has errored.
Task
 InheritednumTimesInterrupted : int
[read-only] Number of times this task has been interrupted.
Task
 InheritednumTimesReset : int
[read-only] Number of times this task has been reset.
Task
 InheritednumTimesStarted : int
[read-only] Number of times this task has been started.
Task
 Inheritedrunning : Boolean
[read-only] The task is currently running.
Task
  synchronous : Boolean
[override] [read-only] The current task can be executed synchronously.
TaskWithClosure
 InheritedtaskIdentifier : String
(Optional) human-readable label for task.
Task
 InheriteduniqueID : Number
[read-only] Unique ID for a task.
Task
Protected Properties
 PropertyDefined By
 Inheritedlogger : ILogger
[read-only] Instance of ILogger to be used for any custom Task logging.
Task
Public Methods
 MethodDefined By
  
TaskWithClosure(customRunFunction:Function = null, autoCompleteAfterRunningFunction:Boolean = false, taskIdentifier:String = null)
Constructor.
TaskWithClosure
 Inherited
and(... chainedTasks):ITask
Executes the specified tasks when the current task is executed.
Task
 Inherited
Task
  
errorTask(message:String, data:* = null):void
Instructs Task to dispatch an error event.
TaskWithClosure
  
finishTask(message:String, data:* = null):void
Instructs Task to complete itself.
TaskWithClosure
 Inherited
interrupt():Boolean
Interruptible tasks should override interrupt() and get interruptible() if they are interruptible.
Task
 Inherited
interruptForTask(interruptingTask:ITask):Boolean
Interrupts the current Task to wait on the Task specified.
Task
 Inherited
or(... chainedTasks):ITask
Executes the specified tasks if the current task fails.
Task
 Inherited
reset():void
Resets the task to it's pre-run state.
Task
 Inherited
Starts a task.
Task
 Inherited
then(... chainedTasks):ITask
Executes the specified tasks once the current task has completed successfully.
Task
 Inherited
withCompleteHandler(completeHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate completion, this method may also be used for notification purposes.
Task
 Inherited
withErrorHandler(errorHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate failure, this method may also be used for notification purposes.
Task
 Inherited
withFinalHandler(finalHandler:Function):ITask
This handler is invoked upon either success or failure of the Task.
Task
 Inherited
withInterruptionHandler(interruptionHandler:Function):ITask
Task
 Inherited
withStartedHandler(startedHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate starting, this method may also be used for notification purposes.
Task
Protected Methods
 MethodDefined By
 Inherited
Override this method to perform any custom reset operations.
Task
  
customRun():void
[override] Override this method to give your Task functionality.
TaskWithClosure
 Inherited
Task
 Inherited
getLoggerString(string:String):String
Returns a string for logging the specified task-state event.
Task
 Inherited
taskComplete(message:String, data:* = null):void
This method should be called upon Task completion.
Task
 Inherited
taskError(message:String, data:* = null):void
This method should be called upon Task failure.
Task
 Inherited
taskInterrupted(message:String, data:* = null):void
Call this method to interrupt the currently running Task.
Task
 Inherited
Task
Events
 Event Summary Defined By
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
Property Detail
autoCompleteAfterRunningFunctionproperty
autoCompleteAfterRunningFunction:Boolean

If TRUE this Task will synchronously complete itself once it has invoked its custom run function. If an error occurs during the functions execution however the Task will not dispatch a redundant complete event.


Implementation
    public function get autoCompleteAfterRunningFunction():Boolean
    public function set autoCompleteAfterRunningFunction(value:Boolean):void
customRunFunctionproperty 
customRunFunction:Function

Function to be executed when this Task is run


Implementation
    public function get customRunFunction():Function
    public function set customRunFunction(value:Function):void
synchronousproperty 
synchronous:Boolean  [read-only] [override]

The current task can be executed synchronously.


Implementation
    public function get synchronous():Boolean
Constructor Detail
TaskWithClosure()Constructor
public function TaskWithClosure(customRunFunction:Function = null, autoCompleteAfterRunningFunction:Boolean = false, taskIdentifier:String = null)

Constructor.

Parameters
customRunFunction:Function (default = null) — Function to be executed when this Task is run
 
autoCompleteAfterRunningFunction:Boolean (default = false) — If TRUE this Task will complete after running custom function (unless custom function called "errorTask")
 
taskIdentifier:String (default = null) — Semantically meaningful task identifier (useful for automated testing or debugging)
Method Detail
customRun()method
override protected function customRun():void

Override this method to give your Task functionality.

errorTask()method 
public function errorTask(message:String, data:* = null):void

Instructs Task to dispatch an error event.

Parameters

message:String
 
data:* (default = null)

finishTask()method 
public function finishTask(message:String, data:* = null):void

Instructs Task to complete itself.

Parameters

message:String
 
data:* (default = null)