public static IEnumerator Cancelable(float x, Action<float> retrun, CoroutToken token) { for (int i = 0; i < 5; i++) yield return null; token.Cancel(); retrun(x * x); }
public static IEnumerator CancelableAfter(int step, float x, Action<float> retrun, CoroutToken token) { token.CancelAfter(step); for (int i = 0; i < 1000; i++) yield return null; retrun(x * x); }
/// <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; }
/// <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(); } }