Class ThreadUtils
- Namespace
- HomaGames.HomaBelly
- Assembly
- HomaGames.HomaBelly.Core.dll
This is a helper class to run code on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo instead.")]
public static class ThreadUtils
- Inheritance
-
ThreadUtils
- Inherited Members
Methods
ContinueWithOnMainThread(Task, Action<Task>)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task ContinueWithOnMainThread(this Task task, Action<Task> action)
Parameters
Returns
- Task
A task describing the whole process.
ContinueWithOnMainThread(Task, Action<Task>, CancellationToken)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task ContinueWithOnMainThread(this Task task, Action<Task> action, CancellationToken token)
Parameters
taskTaskThe task.
actionAction<Task>The action to execute after the task.
tokenCancellationTokenA cancellation token associated to the action execution.
Returns
- Task
A task describing the whole process.
ContinueWithOnMainThread<TResult>(Task, Func<Task, TResult>)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> ContinueWithOnMainThread<TResult>(this Task task, Func<Task, TResult> func)
Parameters
Returns
- Task<TResult>
A task describing the whole process.
Type Parameters
TResultThe return type of the function.
ContinueWithOnMainThread<TResult>(Task, Func<Task, TResult>, CancellationToken)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> ContinueWithOnMainThread<TResult>(this Task task, Func<Task, TResult> func, CancellationToken token)
Parameters
taskTaskThe task.
funcFunc<Task, TResult>The function to execute after the task.
tokenCancellationTokenA cancellation token associated to the function execution.
Returns
- Task<TResult>
A task describing the whole process.
Type Parameters
TResultThe return type of the function.
ContinueWithOnMainThread<TSource>(Task<TSource>, Action<Task<TSource>>)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task ContinueWithOnMainThread<TSource>(this Task<TSource> task, Action<Task<TSource>> action)
Parameters
Returns
- Task
A task describing the whole process.
Type Parameters
TSourceThe return type of the task.
ContinueWithOnMainThread<TSource>(Task<TSource>, Action<Task<TSource>>, CancellationToken)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task ContinueWithOnMainThread<TSource>(this Task<TSource> task, Action<Task<TSource>> action, CancellationToken token)
Parameters
taskTask<TSource>The task.
actionAction<Task<TSource>>The action to execute after the task.
tokenCancellationTokenA cancellation token associated to the action execution.
Returns
- Task
A task describing the whole process.
Type Parameters
TSourceThe return type of the task.
ContinueWithOnMainThread<TSource, TResult>(Task<TSource>, Func<Task<TSource>, TResult>)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> ContinueWithOnMainThread<TSource, TResult>(this Task<TSource> task, Func<Task<TSource>, TResult> func)
Parameters
taskTask<TSource>The task.
funcFunc<Task<TSource>, TResult>The function to execute after the task.
Returns
- Task<TResult>
A task describing the whole process.
Type Parameters
TSourceThe return type of the task.
TResultThe return type of the function.
ContinueWithOnMainThread<TSource, TResult>(Task<TSource>, Func<Task<TSource>, TResult>, CancellationToken)
Acts like ContinueWith, but with the execution on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> ContinueWithOnMainThread<TSource, TResult>(this Task<TSource> task, Func<Task<TSource>, TResult> func, CancellationToken token)
Parameters
taskTask<TSource>The task.
funcFunc<Task<TSource>, TResult>The function to execute after the task.
tokenCancellationTokenA cancellation token associated to the function execution.
Returns
- Task<TResult>
A task describing the whole process.
Type Parameters
TSourceThe return type of the task.
TResultThe return type of the function.
RunAndForgetOnMainThread(Action)
This method will run the given action asynchronously on the main thread.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext.Post instead.")]
public static void RunAndForgetOnMainThread(Action action)
Parameters
actionActionThe action to run on the main thread.
RunOnMainThread(Action)
This method will run the given action on the main thread, and wait for it to be finished
before returning.
If called from the main thread, the action will be executed directly.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.IsMainThread and ThreadInfo.MainThreadSynchronizationContext.Send instead.")]
public static void RunOnMainThread(Action action)
Parameters
actionActionThe action to run on the main thread.
RunOnMainThreadAsync(Action)
This method will run the given action on the main thread asynchronously.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task RunOnMainThreadAsync(Action action)
Parameters
actionActionThe action to execute on the main thread.
Returns
- Task
A task representing the execution of the action.
RunOnMainThreadAsync(Action, CancellationToken)
This method will run the given action on the main thread asynchronously.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task RunOnMainThreadAsync(Action action, CancellationToken cancellationToken)
Parameters
actionActionThe action to execute on the main thread.
cancellationTokenCancellationTokenAn associated cancellation token
Returns
- Task
A task representing the execution of the action.
RunOnMainThreadAsync<TResult>(Func<TResult>)
This method will run the given function on the main thread asynchronously.
If called from the main thread, the function will be executed directly.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> RunOnMainThreadAsync<TResult>(Func<TResult> func)
Parameters
funcFunc<TResult>The function to execute on the main thread.
Returns
- Task<TResult>
A task representing the execution of the function.
Type Parameters
TResultThe return type of the function.
RunOnMainThreadAsync<TResult>(Func<TResult>, CancellationToken)
This method will run the given function on the main thread asynchronously.
If called from the main thread, the function will be executed directly.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.MainThreadSynchronizationContext instead.")]
public static Task<TResult> RunOnMainThreadAsync<TResult>(Func<TResult> func, CancellationToken cancellationToken)
Parameters
funcFunc<TResult>The function to execute on the main thread.
cancellationTokenCancellationTokenA cancellation token to associate with the task.
Returns
- Task<TResult>
A task representing the execution of the function.
Type Parameters
TResultThe return type of the function.
RunOnMainThreadCurrentOrForget(Action)
This method will run the given action on the main thread. If the current thread is the main one, it will run it synchronously. If not, it will run it asynchronously, in a run-and-forget fashion.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.IsMainThread and ThreadInfo.MainThreadSynchronizationContext.Post instead.")]
public static void RunOnMainThreadCurrentOrForget(Action action)
Parameters
actionActionThe action to run on the main thread.
RunOnMainThread<TResult>(Func<TResult>)
This method will run the given function on the main thread, wait for it to finish,
and return the result.
If called from the main thread, the function will be executed directly.
[Obsolete("Use Homa.Sdk.Foundation.ThreadInfo.IsMainThread and ThreadInfo.MainThreadSynchronizationContext.Send instead.")]
public static TResult RunOnMainThread<TResult>(Func<TResult> func)
Parameters
funcFunc<TResult>The function to execute on the main thread.
Returns
- TResult
The return value of the given function.
Type Parameters
TResultThe return type of the function.