Пример #1
0
 public void Abort()
 {
     if (State == ThreadJobState.Running)
     {
         _thread.Abort();
         State = ThreadJobState.Aborted;
     }
 }
Пример #2
0
 public void Start()
 {
     if (State == ThreadJobState.Created)
     {
         State = ThreadJobState.Running;
         _thread.Start();
     }
 }
Пример #3
0
        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;
        }
Пример #4
0
        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);
        }