示例#1
0
        /// <summary>.</summary>
        internal protected Corout(IEnumerator routine)
        {
            this._succeed = new List <Action <Corout> >();
            this._cancel  = new List <Action <Corout> >();
            this._catch   = new List <Action <Corout> >();
            this._finally = new List <Action <Corout> >();

            this._exception = null;
            this._status    = ECoroutStatus.Created;
            this._synchron  = false;
            this._asyncMode = EAsyncMode.Normal;
            this._fenceIdx  = -1;
            this._token     = new CoroutToken();

            this._routine = routine;
        }
示例#2
0
        internal void Start(EAsyncMode asynchronousMode)
        {
            var scheduler = Scheduler.Instance;

            if (scheduler == null)
            {
                throw new NullReferenceException("Scheduler.");
            }

            if (this._status != ECoroutStatus.Created)
            {
                throw new Exception("coroutine already started.");
            }

            this._synchron  = false;
            this._asyncMode = asynchronousMode;
            scheduler.Append(this);
        }
示例#3
0
        /// <summary>.</summary>
        internal protected Corout(Func <CoroutToken, IEnumerator> routine)
        {
            this._succeed = new List <Action <Corout> >();
            this._cancel  = new List <Action <Corout> >();
            this._catch   = new List <Action <Corout> >();
            this._finally = new List <Action <Corout> >();

            this._exception = null;
            this._status    = ECoroutStatus.Created;
            this._synchron  = false;
            this._asyncMode = EAsyncMode.Normal;
            this._fenceIdx  = -1;
            this._token     = new CoroutToken();

            try
            {
                this._routine = routine(this._token);
            }
            catch (Exception ex)
            {
                this.AppendError(ex);
                this.Callback();
            }
        }