Beispiel #1
0
        public static void InitTable(string tableName, Dictionary <int, IRecord> dictionary, TableType type)
        {
            var path = "Table/" + tableName + ".txt";

            ResourceManager.PrepareResource <TextAsset>(path, asset =>
            {
                if (asset == null)
                {
                    Logger.Error("InitTable error! asset = null, assetname = {0}", path);
                    return;
                }

                TableInit.Table_Init((asset as TextAsset).bytes, dictionary, type);
                ResourceManager.Instance.RemoveFromCache("Table/" + tableName + ".unity3d");
            }, true, false, true, true, true);
        }
Beispiel #2
0
        public void LoadTable(object state)
        {
            var path     = string.Format("TableCache/{0}.txt", tableName);
            var realpath = Path.Combine(UpdateHelper.DownloadRoot, path);
            var threadid = Thread.CurrentThread.ManagedThreadId;

            try
            {
                var buffer = File.ReadAllBytes(realpath);
                TableManager.Encrypte(buffer);
                TableInit.Table_Init(buffer, dictionary, type);
            }
            catch (Exception e)
            {
                Debug.LogError("loadTable thread: " + threadid + "tablename:" + tableName + "Exception:" + e);
            }
            finally
            {
                Interlocked.Increment(ref TableManager.LoadCount);
            }
        }
Beispiel #3
0
        public static void InitTable(string tableName, Dictionary <int, IRecord> dictionary, TableType type)
        {
            var exist = CacheExist();

            if (GameSetting.Instance.ThreadLoadTable && exist)
            {
                if (MaxCount == 0)
                {
                    var max = GameSetting.Instance.ThreadCount;
                    ThreadPool.SetMaxThreads(max, max);
                    ThreadPool.SetMinThreads(2, 2);
                }
                MaxCount++;
                var helper = new LoadTableHelper(tableName, dictionary, type);
                ThreadPool.QueueUserWorkItem(helper.LoadTable);

                //----------------------------------sync test
//                 MaxCount++;
//                 var helper = new LoadTableHelper(tableName, dictionary, type);
//                 helper.LoadTable(0);
            }
            else
            {
                var path = "Table/" + tableName + ".txt";
                ResourceManager.PrepareResource <TextAsset>(path, asset =>
                {
                    if (asset == null)
                    {
                        Logger.Error("InitTable error! asset = null, assetname = {0}", path);
                        return;
                    }

                    TableInit.Table_Init((asset as TextAsset).bytes, dictionary, type);
                    ResourceManager.Instance.RemoveFromCache("Table/" + tableName + ".unity3d");
                }, true, false, true, true, true);
            }
        }