예제 #1
0
        // ========================================================================================= Timer event handler

        private static void MaintenanceTimerElapsed(object state)
        {
            // Increment the global cycle counter. Different maintenance tasks may
            // rely on this to decide whether they should be executed in the
            // current cycle.
            Interlocked.Increment(ref _currentCycle);

            // preventing the counter from overflow
            if (_currentCycle > 100000)
            {
                _currentCycle = 0;
            }

            if (SnTrace.System.Enabled)
            {
                SnTrace.System.Write("CPU: {0}%, RAM: {1} KBytes available (working set: {2} bytes)",
                                     CounterManager.GetCPUUsage(),
                                     CounterManager.GetAvailableRAM(),
                                     Environment.WorkingSet);
            }

            // start maintenance tasks asychronously
            Task.Run(() => CleanupFiles());
            Task.Run(() => StartADSync());
        }