/// <summary> /// Creates and starts a thread for our thread manager with a callback to run when completed. /// </summary> /// <param name="functionToRun">The function the thread should run.</param> /// <param name="functionToRunOnComplete">The function the thread should run when it completes it's main task.</param> /// <returns>The created thread</returns> public static CustomThread CreateThread(ThreadStart functionToRun, OnThreadTaskComplete functionToRunOnComplete) { CustomThread thread = CreateThread(functionToRun); thread.OnThreadTaskComplete += functionToRunOnComplete; return thread; }
/// <summary> /// Creates and starts a thread for our thread manager with a callback to run when completed. /// </summary> /// <param name="functionToRun">The function the thread should run.</param> /// <param name="functionToRunOnComplete">The function the thread should run when it completes it's main task.</param> /// <returns>The created thread</returns> public static CustomThread CreateThread(ThreadStart functionToRun, OnThreadTaskComplete functionToRunOnComplete) { CustomThread thread = CreateThread(functionToRun); thread.OnThreadTaskComplete += functionToRunOnComplete; return(thread); }
/// <summary> /// Checks to see if the thread has finished it's main work and calls it's finished callback if necessary. /// </summary> public void Update() { if (Task.IsCompleted || RequestStop) { IsAlive = false; OnThreadTaskComplete?.Invoke(); } }