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 ALL THE MAGIC HAPPENS!
- /// </summary>
- /// <param name="args"></param>
- static void Main(string[] args)
- {
- // This will greet the user in the default voice
- SpeechSynthesizer synth = new SpeechSynthesizer();
- synth.Speak("Welcome to Jarvis version 1.0");
- #region My performance Counters
- // This will pull the current CPU load in percentage
- PerformanceCounter perfCpuCount = new PerformanceCounter("Processor Information", "% Processor time", "_Total");
- // This will pull the current avaible memory in Megabytes
- PerformanceCounter perfMemCount = new PerformanceCounter("Memory", "Available MBytes");
- // This tells how long the system has been running. (in seconds)
- PerformanceCounter perfUpTimeCount = new PerformanceCounter("System", "System Up Time");
- #endregion
- // Infinite While Loop
- while(true)
- {
- // Get the current performance current values.
- float currentCpuPercentage = perfCpuCount.NextValue();
- float currentAvailableMemory = perfMemCount.NextValue();
- // Every 1 second print the CPU load in percentage to the screen
- Console.WriteLine("CPU Load: {0}%", currentCpuPercentage);
- Console.WriteLine("Available Memory: {0}MB", currentAvailableMemory);
- // Speak to the user with text to speech to tell them what the current vaules are
- string cpuLoadVocalMessage = String.Format("The current CPU load is {0} percent", currentCpuPercentage);
- string memAvailableVocalMessage = String.Format("You currently have {0} megabytes of memory available", currentAvailableMemory);
- synth.Speak(cpuLoadVocalMessage);
- synth.Speak(memAvailableVocalMessage);
- Thread.Sleep(1000);
- }// End of loop
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement