Interface IUnityThreadUtils
This component is an utility to simplify working with the Unity thread.
Namespace: Unity.Services.Core.Threading.Internal
Assembly: Unity.Services.Core.Internal.dll
Syntax
public interface IUnityThreadUtils : IServiceComponent
Properties
IsRunningOnUnityThread
Check if the calling thread is the Unity thread.
Declaration
bool IsRunningOnUnityThread { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
PostAsync(Action)
Create a task out of the given action that will be invoked on the Unity thread.
Declaration
Task PostAsync(Action action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | action | The action to invoke on the Unity thread. |
Returns
| Type | Description |
|---|---|
| Task | Return the created task. |
PostAsync(Action<object>, object)
Create a task out of the given action that will be invoked on the Unity thread.
Declaration
Task PostAsync(Action<object> action, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<object> | action | The action to invoke on the Unity thread.
|
| object | state | The captured state to pass to |
Returns
| Type | Description |
|---|---|
| Task | Return the created task. |
PostAsync<T>(Func<object, T>, object)
Create a task out of the given action that will be invoked on the Unity thread.
Declaration
Task<T> PostAsync<T>(Func<object, T> action, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<object, T> | action | The action to invoke on the Unity thread.
|
| object | state | The captured state to pass to |
Returns
| Type | Description |
|---|---|
| Task<T> | Return the created task. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the return of the invoked action. Can be any type. |
PostAsync<T>(Func<T>)
Create a task out of the given action that will be invoked on the Unity thread.
Declaration
Task<T> PostAsync<T>(Func<T> action)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T> | action | The action to invoke on the Unity thread. |
Returns
| Type | Description |
|---|---|
| Task<T> | Return the created task. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the return of the invoked action. Can be any type. |
Send(Action)
Execute the given action on the Unity thread.
Wait for the execution to finish before resuming this thread.
Declaration
void Send(Action action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | action | The action to invoke on the Unity thread. |
Send(Action<object>, object)
Execute the given action on the Unity thread.
Wait for the execution to finish before resuming this thread.
Declaration
void Send(Action<object> action, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<object> | action | The action to invoke on the Unity thread.
|
| object | state | The captured state to pass to |
Send<T>(Func<object, T>, object)
Execute the given action on the Unity thread.
Wait for the execution to finish before resuming this thread.
Declaration
T Send<T>(Func<object, T> action, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<object, T> | action | The action to invoke on the Unity thread.
|
| object | state | The captured state to pass to |
Returns
| Type | Description |
|---|---|
| T | Return what the action returned. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the return of the invoked action. Can be any type. |
Send<T>(Func<T>)
Execute the given action on the Unity thread.
Wait for the execution to finish before resuming this thread.
Declaration
T Send<T>(Func<T> action)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T> | action | The action to invoke on the Unity thread. |
Returns
| Type | Description |
|---|---|
| T | Return what the action returned. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the return of the invoked action. Can be any type. |