internal override void Execute(object[] args) { if (args.Length < 2) { throw new ArgumentException(); } for (var i = 0; i < args.Length - 1; i++) { if (args [i] == null || !(args [i] is ChildFunc)) { throw new ArgumentException(); } } if (args [args.Length - 1] == null || !(args [args.Length - 1] is UAsyncFinalFunc)) { throw new ArgumentException(); } IsFree = false; IsDone = false; completeNum = 0; total = args.Length - 1; finalFunc = args [args.Length - 1] as UAsyncFinalFunc; result.Clear(); funcs.Clear(); ChildFunc func; for (var i = 0; i < args.Length - 1; i++) { func = args [i] as ChildFunc; funcs.Add(func); var name = func.name; if (result.ContainsKey(name)) { Cleanup(); IsDone = true; IsFree = true; throw new ArgumentException("Same name is already used: " + name); } else { result [name] = null; } } RunOneFunc(args [0] as ChildFunc); }
public static UAsyncFinalFunc Create(Action <object> action) { if (action == null) { throw new ArgumentException(); } var finalFunc = LeanClassPool <UAsyncFinalFunc> .Spawn(); if (finalFunc == null) { finalFunc = new UAsyncFinalFunc(); } finalFunc.action2 = action; return(finalFunc); }
override internal void Execute(object[] args) { if (args.Length != 3) { throw new ArgumentException(); } if (!(args [0] is IEnumerable <T>)) { throw new ArgumentException(); } if (args [1] == null || !(args [1] is ChildFunc <T>)) { throw new ArgumentException(); } if (args [args.Length - 1] == null || !(args [args.Length - 1] is UAsyncFinalFunc)) { throw new ArgumentException(); } IsDone = false; IsFree = false; completeNum = 0; var temp = (IEnumerable <T>)args [0]; items.Clear(); items.AddRange(temp.ToList()); total = items.Count; finalFunc = args [args.Length - 1] as UAsyncFinalFunc; if (total == 0) { IsDone = true; IsFree = true; finalFunc.action2(null); return; } func = args [1] as ChildFunc <T>; RunOneFunc(); }
internal override void Execute(object[] args) { if (args.Length != 3) { throw new ArgumentException(); } if (!(args [0] is IEnumerable <T>)) { throw new ArgumentException(); } if (args [1] == null || !(args [1] is ChildFunc <T>)) { throw new ArgumentException(); } if (args [args.Length - 1] == null || !(args [args.Length - 1] is UAsyncFinalFunc)) { throw new ArgumentException(); } IsDone = false; IsFree = false; completeNum = 0; var temp = (IEnumerable <T>)args [0]; items.Clear(); items.AddRange(temp.ToList()); total = items.Count; finalFunc = args [args.Length - 1] as UAsyncFinalFunc; if (total == 0) { IsDone = true; IsFree = true; finalFunc.action2(null); return; } taskRoutines.Clear(); func = args [1] as ChildFunc <T>; for (var i = 0; i < total; i++) { var item = items [i]; if (func.action1 != null) { taskRoutines.Add( TaskRunner.Instance.Run( new SingleTask(() => func.action1(item, Callback)), TaskRunnerCallback) ); } else { taskRoutines.Add( TaskRunner.Instance.Run( func.enumerator1(item, Callback), TaskRunnerCallback) ); } } }
internal override void Execute(object[] args) { if (args.Length < 2) { throw new ArgumentException(); } for (var i = 0; i < args.Length - 1; i++) { if (args [i] == null || !(args [i] is ChildFunc)) { throw new ArgumentException(); } } if (args [args.Length - 1] == null || !(args [args.Length - 1] is UAsyncFinalFunc)) { throw new ArgumentException(); } IsDone = false; IsFree = false; completeNum = 0; total = args.Length - 1; finalFunc = args [args.Length - 1] as UAsyncFinalFunc; result.Clear(); ChildFunc func; for (var i = 0; i < args.Length - 1; i++) { func = args [i] as ChildFunc; funcs.Add(func); var name = func.name; if (result.ContainsKey(name)) { Cleanup(); IsDone = true; IsFree = true; throw new ArgumentException("Same name is already used: " + name); } else { result [name] = null; if (func.action1 != null) { taskRoutines.Add( TaskRunner.Instance.Run( new SingleTask(() => func.action1((err, res) => Callback(name, err, res))), TaskRunnerCallback) ); } else { taskRoutines.Add( TaskRunner.Instance.Run( func.enumerator1((err, res) => Callback(name, err, res)), TaskRunnerCallback) ); } } } }