Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Diagnostics;
  7. using System.Threading;
  8. using System.Speech.Synthesis;
  9.  
  10. namespace Jarvis
  11. {
  12. class Program
  13. {
  14. /// <summary>
  15. /// WHERE ALL THE MAGIC HAPPENS!
  16. /// </summary>
  17. /// <param name="args"></param>
  18. static void Main(string[] args)
  19. {
  20. // This will greet the user in the default voice
  21. SpeechSynthesizer synth = new SpeechSynthesizer();
  22. synth.Speak("Welcome to Jarvis version 1.0");
  23.  
  24. #region My performance Counters
  25. // This will pull the current CPU load in percentage
  26. PerformanceCounter perfCpuCount = new PerformanceCounter("Processor Information", "% Processor time", "_Total");
  27.  
  28. // This will pull the current avaible memory in Megabytes
  29. PerformanceCounter perfMemCount = new PerformanceCounter("Memory", "Available MBytes");
  30.  
  31. // This tells how long the system has been running. (in seconds)
  32. PerformanceCounter perfUpTimeCount = new PerformanceCounter("System", "System Up Time");
  33. #endregion
  34.  
  35. // Infinite While Loop
  36. while(true)
  37. {
  38. // Get the current performance current values.
  39. float currentCpuPercentage = perfCpuCount.NextValue();
  40. float currentAvailableMemory = perfMemCount.NextValue();
  41.  
  42. // Every 1 second print the CPU load in percentage to the screen
  43. Console.WriteLine("CPU Load: {0}%", currentCpuPercentage);
  44. Console.WriteLine("Available Memory: {0}MB", currentAvailableMemory);
  45.  
  46. // Speak to the user with text to speech to tell them what the current vaules are
  47. string cpuLoadVocalMessage = String.Format("The current CPU load is {0} percent", currentCpuPercentage);
  48. string memAvailableVocalMessage = String.Format("You currently have {0} megabytes of memory available", currentAvailableMemory);
  49. synth.Speak(cpuLoadVocalMessage);
  50. synth.Speak(memAvailableVocalMessage);
  51.  
  52. Thread.Sleep(1000);
  53. }// End of loop
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement