Class AsyncOperationBase<TObject> | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class AsyncOperationBase<TObject>

    base class for implemented AsyncOperations, implements the needed interfaces and consolidates redundant code

    Inheritance
    System.Object
    AsyncOperationBase<TObject>
    InitializationOperation
    ChainOperation<TObject, TObjectDependency>
    CompletedOperation<TObject>
    GroupOperation<TObject>
    Namespace: UnityEngine.ResourceManagement.AsyncOperations
    Syntax
    public abstract class AsyncOperationBase<TObject> : IAsyncOperation<TObject>, IAsyncOperation, IEnumerator
    Type Parameters
    Name Description
    TObject

    Constructors

    AsyncOperationBase()

    Constructor.

    Declaration
    protected AsyncOperationBase()

    Fields

    m_Context

    Context object. This is usually set to the IResourceLocation used to start this operation.

    Declaration
    protected object m_Context
    Field Value
    Type Description
    System.Object

    m_Error

    If and error is encountered, an exception is saved in this member.

    Declaration
    protected Exception m_Error
    Field Value
    Type Description
    System.Exception

    m_Key

    The key used to start the operation. This is usually the address.

    Declaration
    protected object m_Key
    Field Value
    Type Description
    System.Object

    m_ReleaseToCacheOnCompletion

    If true, this operation is released to a cache for re-use. Otherwise, it will be garbage collected.

    Declaration
    protected bool m_ReleaseToCacheOnCompletion
    Field Value
    Type Description
    System.Boolean

    m_Result

    The result value of the operation.

    Declaration
    protected TObject m_Result
    Field Value
    Type Description
    TObject

    m_Status

    The status of the operation.

    Declaration
    protected AsyncOperationStatus m_Status
    Field Value
    Type Description
    AsyncOperationStatus

    Properties

    Context

    Gets the context object related to this operation, usually set to the IResourceLocation.

    Declaration
    public object Context { get; protected set; }
    Property Value
    Type Description
    System.Object

    The context object.

    Implements
    IAsyncOperation.Context

    Current

    Declaration
    public object Current { get; }
    Property Value
    Type Description
    System.Object

    IsDone

    Gets a value indicating whether this ResourceManagement.IAsyncOperation is done.

    Declaration
    public virtual bool IsDone { get; }
    Property Value
    Type Description
    System.Boolean

    true if is done; otherwise, false.

    Implements
    IAsyncOperation.IsDone

    IsValid

    used by Validate to ensure operation is in correct state

    Declaration
    public bool IsValid { get; set; }
    Property Value
    Type Description
    System.Boolean
    Implements
    IAsyncOperation.IsValid

    Key

    Gets the key related to this operation, usually set to the address.

    Declaration
    public virtual object Key { get; set; }
    Property Value
    Type Description
    System.Object

    The context object.

    Implements
    IAsyncOperation.Key

    OperationException

    Gets the exception that caused this operation to change its status to Failure.

    Declaration
    public Exception OperationException { get; protected set; }
    Property Value
    Type Description
    System.Exception

    The exception.

    Implements
    IAsyncOperation.OperationException

    PercentComplete

    Gets the percent complete of this operation.

    Declaration
    public virtual float PercentComplete { get; }
    Property Value
    Type Description
    System.Single

    The percent complete.

    Implements
    IAsyncOperation.PercentComplete

    Result

    Declaration
    public TObject Result { get; }
    Property Value
    Type Description
    TObject
    Implements
    IAsyncOperation<T>.Result

    Status

    returns the status of the operation

    Declaration
    public AsyncOperationStatus Status { get; protected set; }
    Property Value
    Type Description
    AsyncOperationStatus

    Enum indicating success or failure of the operation.

    Implements
    IAsyncOperation.Status

    WaitHandle

    Declaration
    public WaitHandle WaitHandle { get; }
    Property Value
    Type Description
    System.Threading.WaitHandle
    Implements
    IAsyncOperation<T>.WaitHandle

    Methods

    InvokeCompletionEvent()

    Call the event handlers for this operation.

    Declaration
    public void InvokeCompletionEvent()

    MoveNext()

    Declaration
    public bool MoveNext()
    Returns
    Type Description
    System.Boolean

    Release()

    Release operation back to internal cache. This can be used to avoid garbage collection.

    Declaration
    public virtual void Release()
    Implements
    IAsyncOperation.Release()

    Reset()

    Declaration
    public void Reset()

    ResetStatus()

    Reset status and error

    Declaration
    public virtual void ResetStatus()
    Implements
    IAsyncOperation.ResetStatus()

    Retain()

    Declaration
    public IAsyncOperation<TObject> Retain()
    Returns
    Type Description
    IAsyncOperation<TObject>
    Implements
    IAsyncOperation<T>.Retain()

    SetResult(TObject)

    Set the result object. Status will be set to AsyncOperationStatus.Succeeded if the value is non-null, otherwise it is set to AsyncOperationStatus.Failed.

    Declaration
    public virtual void SetResult(TObject result)
    Parameters
    Type Name Description
    TObject result

    The value to set result to.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Validate()

    internal integrity check

    Declaration
    public bool Validate()
    Returns
    Type Description
    System.Boolean
    Implements
    IAsyncOperation.Validate()

    Events

    Completed

    Declaration
    public event Action<IAsyncOperation<TObject>> Completed
    Event Type
    Type Description
    System.Action<IAsyncOperation<TObject>>
    Implements
    IAsyncOperation<T>.Completed

    Explicit Interface Implementations

    IAsyncOperation.Completed

    Occurs when completed.

    Declaration
    event Action<IAsyncOperation> IAsyncOperation.Completed
    Returns
    Type Description
    System.Action<IAsyncOperation>
    Implements
    IAsyncOperation.Completed

    IAsyncOperation.Result

    Declaration
    object IAsyncOperation.Result { get; }
    Returns
    Type Description
    System.Object
    Implements
    IAsyncOperation.Result

    IAsyncOperation.Retain()

    Internally marks operations to not automatically release back to the cache.

    Declaration
    IAsyncOperation IAsyncOperation.Retain()
    Returns
    Type Description
    IAsyncOperation

    Passes back this

    Implements
    IAsyncOperation.Retain()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023