Table of Contents

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

bool

status

Get the current status of the async operation.

protected string status

Field Value

string

Properties

Current

IEnumerator.Current implementation.

public object Current { get; }

Property Value

object

IsDone

Returns true if the async operation has finished or false if it is still running.

public bool IsDone { get; }

Property Value

bool

IsSuccessful

Returns true if the async operation completed successfully or false if an error occurred.

public bool IsSuccessful { get; }

Property Value

bool

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

float

ProgressPercentage

Get the current progress percentage of the async operation.

public int ProgressPercentage { get; }

Property Value

int

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

string

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 bool

Was the operation completed successfully

result Object

An 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 bool

Was the operation completed successfully

result Object

An optional result object

Returns

DLCAsync

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 string

The error message for the failure

Returns

DLCAsync

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 string

The error message for the failure

result Object

An 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 int

The current number of tasks that have been completed

total int

The 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 float

The 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 string

The status message

UpdateTasks()

Called when the async operation can perform some logic.

protected virtual void UpdateTasks()