Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Diagnostics;
- using System.Threading;
- using System.Speech.Synthesis;
- namespace Jarvis
- {
- class Program
- {
- /// <summary>
- /// Where The program Starts
- /// </summary>
- /// <param name="args"></param>
- static void Main(string[] args)
- {
- #region My Performance Counters
- //This will pull the current CPU usage
- PerformanceCounter perfCpuCount = new PerformanceCounter("Processor Information", "% Processor Time", "_Total");
- //This will pull the current available Memory in Megabytes
- PerformanceCounter perfMemCount = new PerformanceCounter("Memory", "Available MBytes");
- //This will Pull the System Uptime (In Seconds)
- PerformanceCounter perfUptimeCount = new PerformanceCounter("System", "System Up Time");
- #endregion
- //This will great the User
- SpeechSynthesizer synth = new SpeechSynthesizer();
- //synth.Speak("Welcome To Jarvis Version one point zero");
- //Infinate while Loop
- while (true)
- {
- //Get the Current Performance Counter Values
- int CurrentCpuPercentage = (int)perfCpuCount.NextValue();
- int CurrentAvailableMemory = (int)perfMemCount.NextValue();
- //Every 1 second, print the CPU percentage, Memory Available and System Up time to the screen
- Console.WriteLine("CPU Load: %{0}", CurrentCpuPercentage);
- Console.WriteLine("Available Memory: {0}MB", CurrentAvailableMemory);
- //Only tell us if the CPU is above 80% usage
- if (CurrentCpuPercentage > 80)
- {
- String CpuLoadVocalMessage = String.Format("CPU Load is {0} percent", CurrentCpuPercentage);
- synth.Speak(CpuLoadVocalMessage);
- }
- //Only tell us if the Availble Memory is below 1024 megabytes
- if (CurrentAvailableMemory < 1024)
- {
- String MemAvailableVocalMessage = String.Format("Available Memory is {0} Megabytes", CurrentAvailableMemory);
- synth.Speak(MemAvailableVocalMessage);
- }
- //Wait 1 Second before Running the Loop Again
- Thread.Sleep(1000);
- }//End of Loop
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement