Exemplo n.º 1
0
        /// <summary>
        /// Shutdown and call the onDone callback when the shutdown is complete.
        /// </summary>
        public void ShutDown(System.Action onDone)
        {
            if (Instances.Values.Contains(this))
            {
                Instances.Remove(Name);
            }

            if (GSPlatform == null)
            {
                // If no platform is set, then we were never initialised. We can just return here.
                return;
            }
            // we don't care about the response but to clean up properly we wait for it.
            EndSessionRequest r = new EndSessionRequest(this);

            r.Send((response) =>
            {
                if (_mainLoopTimer != null)
                {
                    _mainLoopTimer.Stop();
                    _mainLoopTimer = null;
                }

                if (_durableWriteTimer != null)
                {
                    _durableWriteTimer.Stop();
                    _durableWriteTimer = null;
                }

                _paused = true;

                Stop(true);

                if (onDone != null)
                {
                    onDone();
                }
            });

            if (Instances.ContainsKey(Name))
            {
                Instances.Remove(Name);
            }
        }
Exemplo n.º 2
0
        private void InitAllTimers()
        {
            if (_mainLoopTimer != null)
            {
                _mainLoopTimer.Stop();
                _mainLoopTimer = null;
            }

            _mainLoopTimer = GSPlatform.GetTimer();
            _mainLoopTimer.Initialize(1000 / 60, ProcessQueues);

            if (_durableWriteTimer != null)
            {
                _durableWriteTimer.Stop();
                _durableWriteTimer = null;
            }

            _durableWriteTimer = GSPlatform.GetTimer();
            _durableWriteTimer.Initialize(1000 / 60, WriteDurableQueueIfDirty);
        }