Exemple #1
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            _timer.Stop();

            // ***
            // *** Dispose the pin.
            // ***
            if (_pin != null)
            {
                _pin.Dispose();
                _pin = null;
            }

            // ***
            // *** Set the Dht object reference to null.
            // ***
            _dht = null;

            // ***
            // *** Stop the high CPU usage simulation.
            // ***
            CpuKiller.StopEmulation();

            base.OnNavigatedFrom(e);
        }
Exemple #2
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            _timer.Stop();

            _pin.Dispose();
            _pin = null;

            _dht = null;

            CpuKiller.StopEmulation();

            base.OnNavigatedFrom(e);
        }
Exemple #3
0
        public static void StartEmulation()
        {
            Task.Factory.StartNew(() =>
            {
                while (!_cancellationTokenSource.IsCancellationRequested)
                {
                    int taskCount = CpuKiller.Random.Next(1000);
                    Task[] tasks  = new Task[taskCount];

                    for (int i = 0; i < taskCount; i++)
                    {
                        CpuKiller taskSimulator = new CpuKiller(TimeSpan.FromSeconds(CpuKiller.Random.Next(60, 3600)));
                        tasks[i] = taskSimulator.Run();
                    }

                    Task.WaitAll(tasks);
                }
            });
        }
Exemple #4
0
        public static void StartEmulation()
        {
            Task.Factory.StartNew(() =>
            {
                while (!_cancellationTokenSource.IsCancellationRequested)
                {
                    int taskCount = CpuKiller.Random.Next(1000);
                    Task[] tasks = new Task[taskCount];

                    for (int i = 0; i < taskCount; i++)
                    {
                        CpuKiller taskSimulator = new CpuKiller(TimeSpan.FromSeconds(CpuKiller.Random.Next(60, 3600)));
                        tasks[i] = taskSimulator.Run();
                    }

                    Task.WaitAll(tasks);
                }
            });
        }