GameTaskis a global, engine-owned async helper built on top of TaskSource. It manages async work for the entire lifetime of the current game session, rather than for a specific object or system within the game.
All GameTask operations are automatically canceled only when the session ends (for example, on a map change or reload). There is no object-level or manual cancellation.
If your async logic belongs to something that does not live for the entire game session—such as entities, components, abilities, or other in-game systems—you should use TaskSource instead, so the async work is canceled when that object is destroyed.
For Example:
a Global Logger that:
Start when the game starts
Not defined by an entity
stop when session ends
public static class PerformanceLogger
{
public static void Start()
{
_ = Run();
}
static async Task Run()
{
while ( true )
{
await GameTask.DelaySeconds(1);
Log.Info($"FPS: {HostStats.Fps}");
}
}
}
once called from a session entry point (like a GameObjectSystemusing ISceneStart) the logger will be active and persist without be attached to something within the game.
TaskSource.It manages async work for the entire lifetime of the current game session, rather than for a specific object or system within the game.
All GameTask operations are automatically canceled only when the session ends (for example, on a map change or reload).
There is no object-level or manual cancellation.
If your async logic belongs to something that does not live for the entire game session—such as entities, components, abilities, or other in-game systems—you should use
TaskSourceinstead, so the async work is canceled when that object is destroyed.For Example:
a Global Logger that:
public static class PerformanceLogger { public static void Start() { _ = Run(); } static async Task Run() { while ( true ) { await GameTask.DelaySeconds(1); Log.Info($"FPS: {HostStats.Fps}"); } } }GameObjectSystemusingISceneStart) the logger will be active and persist without be attached to something within the game.