Skip to content
JuDelCo edited this page May 20, 2021 · 8 revisions

Namespace: Ju.Services

ITaskService

This service provides helper methods to do asynchronous tasks.

void RunOnMainThread(Action action, float delay = 0f);

IPromise WaitUntil(ILinkHandler handle, Func<bool> condition);
IPromise WaitWhile(ILinkHandler handle, Func<bool> condition);
IPromise WaitForSeconds(ILinkHandler handle, float seconds) where T : ITimeDeltaEvent;
IPromise WaitForTicks(ILinkHandler handle, int ticks) where T : ITimeEvent;
IPromise WaitForNextUpdate(ILinkHandler handle);
IPromise WaitForNextFixedUpdate(ILinkHandler handle);

Refs: IPromise, ILinkHandler, ITimeDeltaEvent, ITimeEvent


RunOnMainThread(Action action, float delay = 0f)

Runs the action (with an optional delay) in the next update time event in the main thread.

Useful when you need to run something but you are in another thread context (in a callback of a third party lib for example).

IPromise WaitUntil(ILinkHandler handle, Func<bool> condition)

Waits until the condition is true to resolve the returned promise.

IPromise WaitWhile(ILinkHandler handle, Func<bool> condition)

Waits until the condition is false to resolve the returned promise.

IPromise WaitForSeconds(ILinkHandler handle, float seconds)

Waits an amount of time (seconds) and then resolves the returned promise.

IPromise WaitForTicks(ILinkHandler handle, int ticks)

Waits an amount of frames (ticks) and then resolves the returned promise.

IPromise WaitForNextUpdate(ILinkHandler handle)

Waits until next update and then resolves the returned promise.

IPromise WaitForNextFixedUpdate(ILinkHandler handle)

Waits until next fixed update and then resolves the returned promise.

Clone this wiki locally