EnqueueOnWorker

Queues a one-time, Unity-independent function on the shared worker pool through the runtime manager.

Static worker taskC# API
static void EnqueueOnWorker(Action function);

Description

Use this static method for isolated background work from scripts that do not inherit from MonoBehaviourMultithreaded. Capture all required Unity values before queuing the worker and return final Unity changes through ThreadHarmonizerManager.EnqueueOnMainThread.

One-time operationThe supplied function is queued once and does not become part of a recurring update loop.
Plain data onlyDo not access Transform, GameObject, Input, Time, or other main-thread-only Unity APIs inside the worker function.

Parameters

NameTypeDescription
functionActionA parameterless function with no return value containing Unity-independent background work.

Queue background work without inheritance

using ThreadHarmonizerEngine;
using UnityEngine;

public class StaticScoreFormatter : MonoBehaviour
{
    private void Start()
    {
        int score = 125000;

        ThreadHarmonizerManager.EnqueueOnWorker(() =>
        {
            string formattedScore = score.ToString("N0");

            ThreadHarmonizerManager.EnqueueOnMainThread(() =>
            {
                Debug.Log($"Score: {formattedScore}");
            });
        });
    }
}