hetrodoo / hetrodo.Utilities.MainThread

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hetrodo.Utilities.MainThread

This is a wrapper class for executing heavy calculations without freezing the main thread but still using Unity's api (like transform.position, Instantiate, Destroy, etc).

Reference

MainThread

  •     Exec(System.Action action) //Method Synchronous

    Executes an action on the main thread, and freezes its caller thread until execution.

  •     ExecAsync(System.Action action) //Method Asynchronous

    Executes an action on the main thread without freezing.

  •     IsRunning //Boolean Field

    Tells if you had already initialized the MainThread class.

  •     OnExceptionCaught(Exception ex) //Error Event

    If any exception occurs while executing the actions, this event will be fired.

MainThread.Timing

  •     DeltaTime //Float Field
    Time since last call for each thread.

Tips

Try to minimize MainThread.Exec usage, as every call will add at least 25ms to your code. If you are using the MainThread.ExecAsync in a loop be sure to add a Thread.Sleep to not overflow the execution pool.

About

License:MIT License


Languages

Language:C# 100.0%