Class DLCAsync
- Namespace
- DLCToolkit
- Assembly
- DLCToolkit.dll
An awaitable object that is returned by async operations so you can wait for completion in a coroutine as well as access progress and status information. Used to wait until an async operation has been completed
public class DLCAsync : IEnumerator
- Inheritance
-
DLCAsync
- Implements
- Derived
Fields
isSuccessful
Was the operation successful or did something go wrong.
protected bool isSuccessful
Field Value
status
Get the current status of the async operation.
protected string status
Field Value
Properties
Current
IEnumerator.Current implementation.
public object Current { get; }
Property Value
IsDone
Returns true if the async operation has finished or false if it is still running.
public bool IsDone { get; }
Property Value
IsSuccessful
Returns true if the async operation completed successfully or false if an error occurred.
public bool IsSuccessful { get; }
Property Value
Progress
Get the current progress of the async operation. This is a normalized value between 0-1.
public float Progress { get; protected set; }
Property Value
ProgressPercentage
Get the current progress percentage of the async operation.
public int ProgressPercentage { get; }
Property Value
Result
Get the UnityEngine.Object result of the async operation.
public Object Result { get; protected set; }
Property Value
- Object
Status
Get the current status of the async operation.
public string Status { get; protected set; }
Property Value
Methods
Await(long)
Block the main thread until the async operation has completed. Use with caution. This can cause an infinite loop if the async operation never completes, if the operation is not true async, or if the async operation relies on data from the main thread.
public void Await(long msTimeout = 10000)
Parameters
msTimeout
long
Exceptions
- TimeoutException
The await operation took longer that the specified timeout milliseconds, so was aborted to avoid infinite waiting
Complete(bool, Object)
Complete the operation with the specified success status. This will cause IsDone to become true and Progress to become 1.
public void Complete(bool success, Object result = null)
Parameters
success
boolWas the operation completed successfully
result
ObjectAn optional result object
Completed(bool, Object)
Create a new instance with the specified success status. This will cause IsDone to become true and Progress to become 1.
public static DLCAsync Completed(bool success, Object result = null)
Parameters
success
boolWas the operation completed successfully
result
ObjectAn optional result object
Returns
Error(string)
Create a new instance with an error status. This will cause IsDone to become true and Progress to become 1.
public static DLCAsync Error(string error)
Parameters
error
stringThe error message for the failure
Returns
Error(string, Object)
Complete the operation with an error status. This will cause IsDone to become true and Progress to become 1.
public void Error(string status, Object result = null)
Parameters
status
stringThe error message for the failure
result
ObjectAn optional result object
MoveNext()
IEnumerator.MoveNext() implementation.
public bool MoveNext()
Returns
- bool
True if the enumerator advanced successfully or false if not
Reset()
IEnumerator.Reset() implementation.
public void Reset()
UpdateProgress(int, int)
Update the load progress for this operation. Calculates the progress as a value from 0-1 based on the input values.
protected void UpdateProgress(int current, int total)
Parameters
current
intThe current number of tasks that have been completed
total
intThe total number of tasks that should be completed
UpdateProgress(float)
Update the load progress for this operation. The specified progress value should be in the range of 0-1, and will be clamped if not.
protected void UpdateProgress(float progress)
Parameters
progress
floatThe current progress value between 0-1
UpdateStatus(string)
Update the status message for this operation. Useful to show the current status if a failure occurs.
protected void UpdateStatus(string status)
Parameters
status
stringThe status message
UpdateTasks()
Called when the async operation can perform some logic.
protected virtual void UpdateTasks()