public void CalculateRandomNumberInBackground()
        {
            // execute a one-time background operation and call a completion on the main thread
            // completion is optional and could be null if desired
            EZThread.ExecuteInBackground(CalculateRandomNumberInBackgroundThread, CalculateRandomNumberInBackgroundCompletionOnMainThread);

            // ExecuteInBackground can be called with a single void function if you don't care about completion or the return result, i.e.
            // EZThread.ExecuteInBackground(() => DoBackgroundStuff());
        }
Esempio n. 2
0
        public void CalculateRandomNumberInBackground()
        {
            // execute a one-time background operation and call a completion on the main thread
            //执行一次后台操作,在主线程调用完成
            // completion is optional and could be null if desired
            //可选,如果需要为空的情况
            EZThread.ExecuteInBackground(CalculateRandomNumberInBackgroundThread, CalculateRandomNumberInBackgroundCompletionOnMainThread);

            // ExecuteInBackground can be called with a single void function if you don't care about completion or the return result, i.e.
            //这可以被称为一个void函数如果你不关心完成或返回的结果
            // EZThread.ExecuteInBackground(() => DoBackgroundStuff());
        }
        private void Start()
        {
            // start scaling the circle where the background thread runs in sync with the Update method
            // this would be great for something like pathfinding where the path needs to update every frame in the background
            circleSyncScale = CircleSync.transform.localScale;
            EZThread.BeginThread(ScaleSyncThread, true);

            // start scaling the circle where the background thread runs as fast as possible
            // this could be useful for something like network calls or other external resource loading
            // you will notice this circle appears to randomly change size, that is because
            // the background thread is scaling the circle super fast so when the update method
            // executes to set the actual scale, it will essentially be a random value.
            circleNonSyncScale = CircleNonSync.transform.localScale;
            EZThread.BeginThread(ScaleNonSyncThread, false);
        }
        private static void EnsureCreated()
        {
            if (singleton != null)
            {
                return;
            }
            singletonObject           = new GameObject("EZTHREAD");
            singletonObject.hideFlags = HideFlags.HideAndDontSave;
            singleton = singletonObject.AddComponent <EZThread>();
            GameObject.DontDestroyOnLoad(singleton);

#if !TASK_AVAILABLE
            System.Threading.ThreadPool.SetMinThreads(Environment.ProcessorCount, Environment.ProcessorCount);
            System.Threading.ThreadPool.SetMaxThreads(Environment.ProcessorCount, Environment.ProcessorCount);
#endif
        }
Esempio n. 5
0
        private void Start()
        {
            // start scaling the circle where the background thread runs in sync with the Update method
            //后台线程运行同步更新方法
            // this would be great for something like pathfinding where the path needs to update every frame in the background
            //这将是伟大的东西像寻路的道路需要在后台更新每一帧
            circleSyncScale = CircleSync.transform.localScale;
            EZThread.BeginThread(ScaleSyncThread, true);
            //bool值表示是否与统一同步更新功能。通常你希望这是真的。

            // start scaling the circle where the background thread runs as fast as possible
            //后台线程运行尽可能快
            // this could be useful for something like network calls or other external resource loading
            //这可能是有用的网络调用或其他外部资源加载
            // you will notice this circle appears to randomly change size, that is because
            //你会注意到这个圆似乎随机改变大小,这是因为
            // the background thread is scaling the circle super fast so when the update method
            //后台线程扩展圈非常快所以当更新方法
            // executes to set the actual scale, it will essentially be a random value.
            //实际执行设置规模,它基本上是一个随机值。
            circleNonSyncScale = CircleNonSync.transform.localScale;
            EZThread.BeginThread(ScaleNonSyncThread, false);
        }