Exemple #1
0
        public void QueueWorkingItem(IEnumerator runner)
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.mHost.Stop();

            this.Enabled = false;

            this.Queue.AddLast(new Func <bool>(runner.MoveNext));

            if (this.mStatus != CoroutineStatus.Status.RUNNING)
            {
                this.mStatus = CoroutineStatus.Status.RUNNING;
                this.mHost.QueueWorkingItem(this);
            }

            this.Enabled = true;

            if (this.mHost != null)
            {
                this.mHost.Start();
            }
        }
Exemple #2
0
        public void Resume()
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.mStatus = CoroutineStatus.Status.RUNNING;
            this.Enabled = true;
        }
Exemple #3
0
        public void Pause()
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.mStatus = CoroutineStatus.Status.STOP;
            this.Enabled = false;
        }
Exemple #4
0
        public void Stop()
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.mStatus = CoroutineStatus.Status.STOP;
            this.Enabled = false;
            this.Queue.Clear();
        }
Exemple #5
0
        public void Start()
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.mStatus = CoroutineStatus.Status.RUNNING;
            this.Enabled = true;

            if (this.mHost != null)
            {
                this.mHost.QueueWorkingItem(this);
                this.mHost.Start();
            }
        }
Exemple #6
0
        internal IEnumerator TaskRunner()
        {
            while (this.Queue.Count > 0)
            {
                LinkedListNode <Func <bool> > node = this.Queue.First;
                while (node != null)
                {
                    LinkedListNode <Func <bool> > next = node.Next;

                    bool nodeCanContinue = true;
                    try
                    {
                        nodeCanContinue = node.Value();
                    }
                    catch (Exception ee)
                    {
                        nodeCanContinue = false;
                        Tracer.D(ee.ToString());
                    }

                    try
                    {
                        if (!nodeCanContinue)
                        {
                            this.Queue.Remove(node);
                        }
                    }
                    catch (Exception)
                    {
                    }

                    node = next;
                    yield return(true);
                }
            }

            if (this.Queue.Count == 0)
            {
                this.mStatus = CoroutineStatus.Status.READY;
            }

            yield break;
        }
Exemple #7
0
        public void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.IsDisposed = true;
            this.Enabled    = false;

            try
            {
                this.mStatus = CoroutineStatus.Status.STOP;
                this.Queue.Clear();
            }
            catch (Exception ee)
            {
                Tracer.D(ee.ToString());
            }
        }