Table of Contents

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

task Task

The task.

action Action<Task>

The action to execute after the task.

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

task Task

The task.

action Action<Task>

The action to execute after the task.

token CancellationToken

A 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

task Task

The task.

func Func<Task, TResult>

The function to execute after the task.

Returns

Task<TResult>

A task describing the whole process.

Type Parameters

TResult

The 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

task Task

The task.

func Func<Task, TResult>

The function to execute after the task.

token CancellationToken

A cancellation token associated to the function execution.

Returns

Task<TResult>

A task describing the whole process.

Type Parameters

TResult

The 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

task Task<TSource>

The task.

action Action<Task<TSource>>

The action to execute after the task.

Returns

Task

A task describing the whole process.

Type Parameters

TSource

The 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

task Task<TSource>

The task.

action Action<Task<TSource>>

The action to execute after the task.

token CancellationToken

A cancellation token associated to the action execution.

Returns

Task

A task describing the whole process.

Type Parameters

TSource

The 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

task Task<TSource>

The task.

func Func<Task<TSource>, TResult>

The function to execute after the task.

Returns

Task<TResult>

A task describing the whole process.

Type Parameters

TSource

The return type of the task.

TResult

The 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

task Task<TSource>

The task.

func Func<Task<TSource>, TResult>

The function to execute after the task.

token CancellationToken

A cancellation token associated to the function execution.

Returns

Task<TResult>

A task describing the whole process.

Type Parameters

TSource

The return type of the task.

TResult

The 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

action Action

The 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

action Action

The 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

action Action

The 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

action Action

The action to execute on the main thread.

cancellationToken CancellationToken

An 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

func Func<TResult>

The function to execute on the main thread.

Returns

Task<TResult>

A task representing the execution of the function.

Type Parameters

TResult

The 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

func Func<TResult>

The function to execute on the main thread.

cancellationToken CancellationToken

A cancellation token to associate with the task.

Returns

Task<TResult>

A task representing the execution of the function.

Type Parameters

TResult

The 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

action Action

The 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

func Func<TResult>

The function to execute on the main thread.

Returns

TResult

The return value of the given function.

Type Parameters

TResult

The return type of the function.