Beispiel #1
0
        private bool RunAtIndex(int index)
        {
            Corout corout = this._runningCorouts[index];

            if (corout != null)
            {
                if (corout.IsFence)
                {
                    if (index > corout.FenceIndex)
                    {
                        return(false);
                    }

                    corout.MoveNext();
                    //while (corout.MoveNext()) { };
                    //return (true);
                }

                bool nxt = false;

                do
                {
                    nxt = corout.MoveNext();

                    if (!nxt)
                    {
                        this._coroutsToRemove.Enqueue(corout);
                    }
                } while (nxt && corout.IsSynchronous);

                if ((corout.AsyncMode == EAsyncMode.Priorize) || (corout.AsyncMode == EAsyncMode.Deferize))
                {
                    return(false);
                }
            }
            else
            {
                this._runningCorouts.RemoveAt(index);
            }


            return(true);
        }
Beispiel #2
0
        public static Corout <T> Create <T>(Action <Corout <T> > callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            var co = new Corout <T>().OnSucceed(callback);

            co.MoveNext();

            return(co);
        }