C# Class UnityTools.Threading.UnityTask

A helper class inspired by the .NET 4.0 Task object and javascript flow libraries such as Q
Datei anzeigen Open project: NoxHarmonium/unity-tools Class Usage Examples

Protected Properties

Property Type Description
_dispatcher IDispatcher
_endCallbacks List
_exception System.Exception
_failureCallbacks List>
_finished bool
_progressCallbacks List>
_result object
_succeeded bool
_successCallbacks List>
_thread Thread
_waitHandle System.Threading.EventWaitHandle

Public Methods

Method Description
All ( ) : UnityTask

Combines multiple tasks of the same type into one callback and runs them simultaneously. On failure the failure callback is called immediately and the result of the other tasks is discarded.

AllSequential ( ) : UnityTask

Combines multiple tasks of the same type into one callback and runs them sequentially. On failure the failure callback is called immediately and the result of the other tasks is discarded.

Notify ( float progress ) : void

Fire all the progress callbacks with the current progress

Reject ( Exception error ) : UnityTask

Finish the task with an error state

Resolve ( object value = null ) : UnityTask

Finish the task with a result

Then ( Action onFulfilled = null, Action onFailure = null, Action onProgress = null, System.Action onEnd = null ) : UnityTask

Add callbacks that will fire on certain task states. If the task has already completed or failed, the related callbacks will fire immediately. Returns the this task so that calls can be chained together.

UnityTask ( IDispatcher dispatcher = null ) : System

Initializes a new instance of the UnityTask`1 class.

UnityTask ( UnityTaskAutoThreadDelegate taskAction, IDispatcher dispatcher = null ) : System

Initializes a new instance of the UnityTask`1 class which wraps an action, automatically running it on a new thread. All uncaught exceptions thrown in the spawned thread will automatically trigger Task.Reject().

Private Methods

Method Description
All ( IDispatcher dispatcher ) : UnityTask

Combines multiple tasks of the same type into one callback and runs them simultaneously. On failure the failure callback is called immediately and the result of the other tasks is discarded.

AllSequential ( IDispatcher dispatcher ) : UnityTask

Combines multiple tasks of the same type into one callback and runs them sequentially. On failure the failure callback is called immediately and the result of the other tasks is discarded.

FireEndCallbacks ( ) : void

Called internally to trigger all the onEnd callbacks

Method Details

All() public static method

Combines multiple tasks of the same type into one callback and runs them simultaneously. On failure the failure callback is called immediately and the result of the other tasks is discarded.
public static All ( ) : UnityTask
return UnityTask

AllSequential() public static method

Combines multiple tasks of the same type into one callback and runs them sequentially. On failure the failure callback is called immediately and the result of the other tasks is discarded.
public static AllSequential ( ) : UnityTask
return UnityTask

Notify() public method

Fire all the progress callbacks with the current progress
public Notify ( float progress ) : void
progress float A floating point value representing the current progress
return void

Reject() public method

Finish the task with an error state
public Reject ( Exception error ) : UnityTask
error System.Exception Error details.
return UnityTask

Resolve() public method

Finish the task with a result
public Resolve ( object value = null ) : UnityTask
value object The result of the task.
return UnityTask

Then() public method

Add callbacks that will fire on certain task states. If the task has already completed or failed, the related callbacks will fire immediately. Returns the this task so that calls can be chained together.
public Then ( Action onFulfilled = null, Action onFailure = null, Action onProgress = null, System.Action onEnd = null ) : UnityTask
onFulfilled Action Callback that fires when the task succeeds
onFailure Action Callback that fires when the task fails
onProgress Action Callback that fires when the progress of the task changes
onEnd System.Action Callback that fires when the task succeeds or fails
return UnityTask

UnityTask() public method

Initializes a new instance of the UnityTask`1 class.
public UnityTask ( IDispatcher dispatcher = null ) : System
dispatcher IDispatcher
return System

UnityTask() public method

Initializes a new instance of the UnityTask`1 class which wraps an action, automatically running it on a new thread. All uncaught exceptions thrown in the spawned thread will automatically trigger Task.Reject().
public UnityTask ( UnityTaskAutoThreadDelegate taskAction, IDispatcher dispatcher = null ) : System
taskAction UnityTaskAutoThreadDelegate The delegate that will be executed on a seperate thread.
dispatcher IDispatcher
return System

Property Details

_dispatcher protected_oe property

protected IDispatcher _dispatcher
return IDispatcher

_endCallbacks protected_oe property

protected List _endCallbacks
return List

_exception protected_oe property

protected Exception,System _exception
return System.Exception

_failureCallbacks protected_oe property

protected List> _failureCallbacks
return List>

_finished protected_oe property

protected bool _finished
return bool

_progressCallbacks protected_oe property

protected List> _progressCallbacks
return List>

_result protected_oe property

protected object _result
return object

_succeeded protected_oe property

protected bool _succeeded
return bool

_successCallbacks protected_oe property

protected List> _successCallbacks
return List>

_thread protected_oe property

protected Thread _thread
return Thread

_waitHandle protected_oe property

protected EventWaitHandle,System.Threading _waitHandle
return System.Threading.EventWaitHandle