Beispiel #1
0
        public void DoWork(object obj)
        {
            Singleton <Log> .Instance.WriteInfo("server core launch");

            _Run = true;
            _Core.Launch();

            while (_Run)
            {
                if (_Binders.Count > 0)
                {
                    lock (_Binders)
                    {
                        while (_Binders.Count > 0)
                        {
                            var provider = _Binders.Dequeue();
                            _Core.AssignBinder(provider);
                        }
                    }
                }


                _RequesterHandlers.Working();
                _AutoPowerRegulator.Operate();
            }

            _Core.Shutdown();
            ShutdownEvent();
            Singleton <Log> .Instance.WriteInfo("server core shutdown");
        }
Beispiel #2
0
        void _Update()
        {
            AutoPowerRegulator regulator = new AutoPowerRegulator(new PowerRegulator());

            while (_Enable)
            {
                _Updater();
                regulator.Operate();
            }
        }
        void _Update(CancellationToken token)
        {
            AutoPowerRegulator regulator = new AutoPowerRegulator(new PowerRegulator());

            while (!token.IsCancellationRequested)
            {
                _Updater();
                regulator.Operate();
            }
        }
Beispiel #4
0
        internal void Run(object obj)
        {
            var are = (AutoResetEvent)obj;

            var powerRegulator     = new PowerRegulator(10);
            var autoPowerRegulator = new AutoPowerRegulator(powerRegulator);

            while (_HasValue == false)
            {
                autoPowerRegulator.Operate();
            }

            are.Set();
        }
Beispiel #5
0
        private void Run()
        {
            AutoPowerRegulator wait = new AutoPowerRegulator(new PowerRegulator(30));

            Updater <Timestamp> updater = new Updater <Timestamp>();

            updater.Add(m_Agent);
            while (m_Enable)
            {
                m_Time.Sample();
                updater.Working(new Timestamp(m_Time.Now, m_Time.Delta));
                wait.Operate();
            }
            updater.Shutdown();
        }
Beispiel #6
0
        private void Run(object State)
        {
            var updater = new Updater <Timestamp>();

            updater.Add(m_Host);

            var wait = new AutoPowerRegulator(new PowerRegulator());

            while (m_Enable)
            {
                m_Time.Sample();
                updater.Working(new Timestamp(m_Time.Now, m_Time.Delta));
                wait.Operate();
            }

            updater.Shutdown();
        }
        public void DoWork(object obj)
        {
            Singleton <Log> .Instance.WriteInfo("server peer launch");

            var are = (AutoResetEvent)obj;

            _Run = true;

            _Server.AcceptEvent += _Accept;
            _Server.Bind(_Port);

            while (_Run)
            {
                if (_Sockets.Count > 0)
                {
                    lock (_Sockets)
                    {
                        while (_Sockets.Count > 0)
                        {
                            var socket = _Sockets.Dequeue();

                            Singleton <Log> .Instance.WriteInfo(
                                string.Format("peer accept Remote {0} Local {1} .", socket.RemoteEndPoint, socket.LocalEndPoint));

                            var peer = new Peer(socket, _Protocol);

                            _Peers.Join(peer);

                            _CoreHandler.Push(peer.Binder, peer.Handler);
                        }
                    }
                }

                _AutoPowerRegulator.Operate();
            }

            _Peers.Release();


            _Server.AcceptEvent -= _Accept;
            _Server.Close();


            are.Set();
            Singleton <Log> .Instance.WriteInfo("server peer shutdown");
        }