Example #1
0
        /***********************************************************************************************************/


        #region ------ Constructor ------


        private MemoryManager(bool bAutoForceGCCollect, bool bAutoReduceWorkingSet)
        {
            AssemblySettings settings = new AssemblySettings();

            try
            {
                _forceGCCollectInterval = new TimeSpan(0, Int32.Parse(settings["ForceGCCollectInterval"].Trim()), 0).Ticks;
            }
            catch
            {
                _forceGCCollectInterval = new TimeSpan(0, 30, 0).Ticks;
            }

            try
            {
                _reduceWorkingSetInterval = new TimeSpan(0, 0, Int32.Parse(settings["ReduceWorkingSetInterval"].Trim())).Ticks;
            }
            catch
            {
                _reduceWorkingSetInterval = new TimeSpan(0, 0, 5).Ticks;
            }

            _bAutoReduceWorkingSet = bAutoReduceWorkingSet;
            _bAutoForceGCCollect   = bAutoForceGCCollect;
            _bFlushMemory          = false;
            Application.Idle      += new EventHandler(ReduceMemoryUsage);
        }
        /***********************************************************************************************************/


        #region ----- Constructor & Destructor ------


        /// <summary>
        /// Constructor.
        /// </summary>
        public InternetConnection(ILog log)
        {
            this._log = log;

            AssemblySettings settings = new AssemblySettings();

            string sInterval = settings["CheckInternetInterval"].Trim();

            if (string.IsNullOrEmpty(sInterval))
            {
                log.Warn("Key CheckInternetInterval in OGameLib.dll.config file is not defined.");
            }
            else
            {
                _CheckInternetInterval = Int32.Parse(sInterval) * 1000;
            }

            _timer          = new System.Windows.Forms.Timer();
            _timer.Tick    += new EventHandler(Timer_Tick);
            _timer.Interval = _CheckInternetInterval;
            _timer.Start();
        }