コード例 #1
0
        public void StartCoroutine(PausableTask task)
        {
            paused = false;

            _newTaskRoutines.Enqueue(task);

            MemoryBarrier();

            if (_isAlive == false)
            {
                _isAlive = true;
                MemoryBarrier();

#if NETFX_CORE
                IAsyncAction asyncAction = ThreadPool.RunAsync
                                               ((workItem) =>
                {
                    RunCoroutineFiber();

                    _isAlive = false;
                    stopped  = false;
                    Interlocked.MemoryBarrier();
                });
#else
                ThreadPool.QueueUserWorkItem((stateInfo) => //creates a new thread only if there isn't any running. It's always unique
                {
                    RunCoroutineFiber();

                    _isAlive = false;
                    stopped  = false;
                    MemoryBarrier();
                });
#endif
            }
        }
コード例 #2
0
    public TaskRoutine CreateTask(IEnumerator task)
    {
        if (task == null)
            return null;

        PausableTask ptask = new PausableTask(task, _runner);

        return new TaskRoutine(ptask);
    }
コード例 #3
0
        public void StartCoroutine(IEnumerator task)
        {
            stopped = false;
            paused = false;

            PausableTask stask;

            if (task is PausableTask)
                stask = task as PausableTask;
            else
                stask = new PausableTask(task, this); //ptask uses a single task internally

            Thread oThread = new Thread(new ThreadStart(() => { while (stask.MoveNext() == true); }));

            oThread.IsBackground = true;
            oThread.Priority = _priority;
            oThread.Start();
        }
コード例 #4
0
        public void StartCoroutine(IEnumerator task)
        {
            stopped = false;
            paused = false;

            if (_component == null)
                if (MonoTaskBehaviour.isQuitting == false)
                    Init();
                else
                    return;

            PausableTask stask;

            if (task is PausableTask)
                stask = task as PausableTask;
            else
                stask = new PausableTask(task, this); //ptask uses a single task internally

            _component.gameObject.SetActive(true);
            _component.enabled = true;
            _component.StartCoroutine(stask);
        }
コード例 #5
0
 internal TaskRoutine(PausableTask task)
 {
     _task = task;
 }
コード例 #6
0
 public void StartCoroutineThreadSafe(PausableTask task)
 {
     StartCoroutine(task);
 }