Class AsyncInitHelper<T>
Utility for resources in Unity components that need asynchronous initialization, and don't match well the Unity synchronous enable/disable workflow.
Inherited Members
Namespace: Microsoft.MixedReality.WebRTC.Unity
Assembly: cs.temp.dll.dll
Syntax
public class AsyncInitHelper<T>
where T : class, IDisposable
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
This keeps track of an initialization task, allows callers to poll for the initialized object, and handles cancellation/cleanup if the initialization is aborted before it has completed.
Properties
Result
Check if the initialization task has generated a result.
Declaration
public T Result { get; }
Property Value
| Type | Description |
|---|---|
| T | The result of the initialization task if there is one and it has just successfully completed;
|
Remarks
If the initialization fails with an exception, this rethrows the exception.
Methods
AbortInitTask()
Cancel the initialization task and dispose its result when it completes.
Declaration
public Task AbortInitTask()
Returns
| Type | Description |
|---|---|
| Task | A |
Remarks
Any exceptions from the initialization task are silently dropped.
TrackInitTask(Task<T>, CancellationTokenSource)
Starts tracking an initialization task for a resource.
Declaration
public void TrackInitTask(Task<T> initTask, CancellationTokenSource cts = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | initTask | |
| CancellationTokenSource | cts | This will be used to cancel the task if aborted before it has finished. Will be disposed at the end of the task. |