private void RegisterGameData <T>() where T : class, new() { Type t = typeof(DataReader <T>); MethodInfo method = t.GetMethod("LoadData", 24); if (this.LoadWrapList.Exists((LoginLoadingRes.GameDataLoadWrap x) => x.GameDataType == t)) { Debug.LogErrorFormat("注册了重复的表格: {0}", new object[] { typeof(T).get_Name() }); } else { TextAsset textAsset = (TextAsset)method.Invoke(null, null); if (textAsset != null) { LoginLoadingRes.GameDataLoadWrap gameDataLoadWrap = new LoginLoadingRes.GameDataLoadWrap { GameDataType = t, GameDataContent = textAsset.get_bytes() }; this.LoadWrapList.Add(gameDataLoadWrap); } } }
private LoginLoadingRes.GameDataLoadWrap GetNextDescend() { LoginLoadingRes.GameDataLoadWrap result = null; object loadingLock = this.LoadingLock; lock (loadingLock) { this.LoadingIndexDescend--; if (this.LoadingIndex < this.LoadingIndexDescend) { result = this.LoadWrapList.get_Item(this.LoadingIndexDescend); } } return(result); }
private void MultThreadLoadDataByDescend(object threadIdx) { try { LoginLoadingRes.GameDataLoadWrap nextDescend = this.GetNextDescend(); object[] param = new object[1]; int num = 0; while (nextDescend != null) { num++; nextDescend.InitData(param); nextDescend = this.GetNextDescend(); this.LoadedCount++; } } catch (Exception ex) { this.AddThreadEx(ex); } }
private void DoLoadGameData() { try { for (int i = 0; i < this.LoadWrapList.get_Count(); i++) { LoginLoadingRes.GameDataLoadWrap gameDataLoadWrap = this.LoadWrapList.get_Item(i); MethodInfo method = gameDataLoadWrap.GameDataType.GetMethod("PrepareSerializer", 24); method.Invoke(null, null); } for (int j = 0; j < this.MultThreadCount - 1; j++) { Thread thread = new Thread(new ParameterizedThreadStart(this.MultThreadLoadDataByDescend)); thread.set_Priority(4); thread.Start(j); } this.MultThreadLoadData(); } catch (Exception ex) { this.AddThreadEx(ex); } }