public static async ETTask LoadAsync(this ConfigComponent self) { self.AllConfig.Clear(); HashSet <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute)); Dictionary <string, byte[]> configBytes = new Dictionary <string, byte[]>(); self.ConfigLoader.GetAllConfigBytes(configBytes); async ETTask Load(Type configType, Dictionary <string, byte[]> configBytes) { await ETTask.CompletedTask; self.LoadOneInThread(configType, configBytes); } MonoListComponent <ETTask> tasks = MonoListComponent <ETTask> .Create(); foreach (var item in types) { tasks.List.Add(Load(item, configBytes)); //好像这么写还是同步加载 } await ETTaskHelper.WaitAll(tasks.List); tasks.Dispose(); }
public static void Load(this ConfigComponent self) { self.AllConfig.Clear(); HashSet <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute)); Dictionary <string, byte[]> configBytes = new Dictionary <string, byte[]>(); ConfigComponent.GetAllConfigBytes(types, configBytes); foreach (Type type in types) { self.LoadOneInThread(type, configBytes); } }
public static async ETTask LoadAsync(this ConfigComponent self) { self.AllConfig.Clear(); HashSet <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute)); Dictionary <string, byte[]> configBytes = new Dictionary <string, byte[]>(); ConfigComponent.GetAllConfigBytes(types, configBytes); List <Task> listTasks = new List <Task>(); foreach (Type type in types) { Task task = Task.Run(() => self.LoadOneInThread(type, configBytes)); listTasks.Add(task); } await Task.WhenAll(listTasks.ToArray()); }
public static async ETTask AdsLoadAsync(this ConfigComponent self, string pAdsLableKey) { self.AllConfig.Clear(); HashSet <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute)); Dictionary <string, byte[]> configBytes = new Dictionary <string, byte[]>(); await ConfigComponent.AdsGetAllConfigBytes(configBytes, pAdsLableKey); await Task.WhenAll((from type in types where configBytes.ContainsKey(type.Name) select Task.Run(() => self.LoadOneInThread(type, configBytes))).ToArray()); }