Exemplo n.º 1
0
        private void OnDisposableReady(BaseDisposable disposable)
        {
            if (owner.isReleased)
            {
                return;
            }

            disposableNotReady.Remove(disposable.id);

            if (VERBOSE)
            {
                Debug.Log($"{owner.sceneData.basePosition} Disposable objects left... {disposableNotReady.Count}");
            }

            if (disposableNotReady.Count == 0)
            {
                SetSceneReady();
            }

            OnStateRefreshed?.Invoke(owner);
            owner.RefreshName();
        }
Exemplo n.º 2
0
        private void OnDisposableReady(ISharedComponent component)
        {
            if (owner.isReleased)
            {
                return;
            }

            disposableNotReady.Remove(component.id);

            if (VERBOSE)
            {
                Debug.Log($"{owner.sceneData.basePosition} Disposable objects left... {disposableNotReady.Count}");
            }

            if (disposableNotReady.Count == 0)
            {
                SetSceneReady();
            }

            OnStateRefreshed?.Invoke(owner);
            owner.RefreshLoadingState();
        }
        /// <summary>
        /// Обновить состояние процесса
        /// </summary>
        public override void RefreshState()
        {
            try
            {
                (double cpu, double memory)lastState = (ProcessState.Cpu, ProcessState.Memory);

                ProcessState.Cpu = Math.Round(_cpuPerformanceCounter.NextValue() / Environment.ProcessorCount, 2);
                //приводим к Mb
                ProcessState.Memory = Math.Round(_ramPerformanceCounter.NextValue() / 1024 / 1024, 2);

                //Если состояние не изменилось, ничего не делаем
                if (ProcessState.Cpu.Equals(lastState.cpu) &&
                    ProcessState.Memory.Equals(lastState.memory))
                {
                    return;
                }

                OnStateRefreshed?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception e)
            {
                OnClosed?.Invoke(this, new ErrorEventArgs(e));
            }
        }