Exemple #1
0
        public System.Collections.Generic.IEnumerator <byte> ForEachAsync <T>(System.Action onComplete, System.Action <T, int> onItem = null) where T : IComponent
        {
            var lr = new ME.LongrunTimer();

            for (int i = 0, capacity = this.Count(); i < capacity; ++i)
            {
                if (this == null)
                {
                    yield break;
                }

                var instance = this.GetItem <T>(i);
                if (instance != null && onItem != null)
                {
                    onItem.Invoke(instance, i);
                }

                if (lr.ShouldPause() == true)
                {
                    yield return(0);

                    lr.Reset();
                }
            }

            if (onComplete != null)
            {
                onComplete.Invoke();
            }
        }
        private IEnumerator CachePreloaded()
        {
            var lr = new ME.LongrunTimer();

            for (int i = 0; i < this.preloadedResources.Count; ++i)
            {
                var resourceKey = this.preloadedResources[i].key;
                this.resources.Add(resourceKey, new ResourceEntity()
                {
                    resource = this.preloadedResources[i].resource
                });

                if (lr.ShouldPause() == true)
                {
                    yield return(0);

                    lr.Reset();
                }
            }

            this.preloadedResources.Clear();
        }
Exemple #3
0
        private System.Collections.Generic.IEnumerator <byte> SetItemsAsync_INTERNAL <T>(int capacity, System.Action onComplete, System.Action <T, int> onItem = null) where T : IComponent
        {
            var lr = new ME.LongrunTimer();

            for (int i = 0; i < capacity; ++i)
            {
                var instance = this.AddItem <T>(autoRefresh: false);
                if (instance is WindowComponent)
                {
                    (instance as WindowComponent).showOnStart = false;
                }
                if (instance != null && onItem != null)
                {
                    onItem.Invoke(instance, i);
                }

                if (lr.ShouldPause() == true)
                {
                    yield return(0);

                    lr.Reset();
                }
            }

            if (onComplete != null)
            {
                onComplete.Invoke();
            }

            this.ForEach <T>((item, idx) => {
                if (item is WindowComponent)
                {
                    (item as WindowComponent).Show();
                }
            });

            this.Refresh(withNoElements: true);
        }