Interface IUnityThreadUtils
This component is an utility to simplify working with the Unity thread.
Namespace: Unity.Services.Core.Threading.Internal
Syntax
public interface IUnityThreadUtils : IServiceComponent
Properties
IsRunningOnUnityThread
Check if the calling thread is the Unity thread.
Declaration
bool IsRunningOnUnityThread { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
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<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. |
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. |
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<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. |
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. |