public void Abort() { if (State == ThreadJobState.Running) { _thread.Abort(); State = ThreadJobState.Aborted; } }
public void Start() { if (State == ThreadJobState.Created) { State = ThreadJobState.Running; _thread.Start(); } }
protected void _initJob(Action action) { action += () => { if (State != ThreadJobState.Aborted && State != ThreadJobState.Faulted) { State = ThreadJobState.Finished; } if (_nextJob != null && State != ThreadJobState.Aborted) { _nextJob.Start(); } }; _thread = new ThreadEx(action); State = ThreadJobState.Created; }
public ThreadJob ContinueWith(Action <ThreadJob> action) { Action _action = () => { try { action(this); } catch (Exception e) { Debug.LogError("UnityTask Excepetion Message: " + e.Message); State = ThreadJobState.Faulted; throw; } }; ThreadJob job = new ThreadJob(_action); _nextJob = job; return(job); }