using System.Collections.Generic; namespace Fort23.Core { public static class CTaskHelper { // private class CoroutineBlocker // { // private int count; // // private List tcss = new List(); // // public CoroutineBlocker(int count) // { // this.count = count; // } // // public async CTask WaitAsync() // { // --this.count; // if (this.count < 0) // { // return; // } // // if (this.count == 0) // { // List t = this.tcss; // this.tcss = null; // foreach (CTask ttcs in t) // { // ttcs.SetResult(); // } // // return; // } // // CTask tcs = CTask.Create(); // // tcss.Add(tcs); // await tcs; // } // } // public static async CTask WaitAll(List> tasks) // { // if (tasks.Count == 0) // { // return false; // } // // CoroutineBlocker coroutineBlocker = new CoroutineBlocker(tasks.Count + 1); // foreach (CTask task in tasks) // { // RunOneTask(task); // } // // async void RunOneTask(CTask task) // { // await task; // await coroutineBlocker.WaitAsync(); // } // await coroutineBlocker.WaitAsync(); // return true; // } // public static async CTask WaitAll(List tasks) // { // if (tasks.Count == 0) // { // return false; // } // // CoroutineBlocker coroutineBlocker = new CoroutineBlocker(tasks.Count + 1); // foreach (CTask task in tasks) // { // RunOneTask(task); // // } // // await coroutineBlocker.WaitAsync(); // // async void RunOneTask(CTask task) // { // await task; // await coroutineBlocker.WaitAsync(); // } // return true; // } } }