Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public FrmMain(string userName, string password)
  2. {
  3. InitializeComponent();
  4.  
  5. HomeLoadOfflineHelper.HomeLoadOffline(userName, password);
  6.  
  7. txbUserName = userName;
  8.  
  9. ph = new PageHome(userName, password);
  10. pm = new PageMonitoring();
  11. pa = new PageAboutus();
  12.  
  13. DataContext = this;
  14. }
  15.  
  16. public PageMonitoring()
  17. {
  18. InitializeComponent();
  19. InitializeNetworkInterface();
  20.  
  21. Task.Run(() =>
  22. {
  23.  
  24. short Counter = 0;
  25.  
  26. LessPingSeries = new ChartValues<ObservableValue> { };
  27. NormalPingSeries = new ChartValues<ObservableValue> { };
  28. DownloadSeries = new ChartValues<ObservableValue> { };
  29. UploadSeries = new ChartValues<ObservableValue> { };
  30.  
  31. while (true)
  32. {
  33. Thread.Sleep(2000);
  34.  
  35. MessageBox.Show("OK");
  36.  
  37. using (Ping ping = new Ping())
  38. {
  39. LessPingSeries.Add(new ObservableValue(ping.Send("8.8.8.8").RoundtripTime));
  40. NormalPingSeries.Add(new ObservableValue(ping.Send("4.2.2.4").RoundtripTime));
  41. }
  42.  
  43. DownloadSeries.Add(new ObservableValue(ByteSize.FromBytes(bytesReceivedSpeed).MegaBytes));
  44. UploadSeries.Add(new ObservableValue(ByteSize.FromBytes(bytesSentSpeed).MegaBytes));
  45.  
  46. Counter++;
  47. if (Counter >= 5)
  48. {
  49. LessPingSeries.RemoveAt(0);
  50. NormalPingSeries.RemoveAt(0);
  51.  
  52. DownloadSeries.RemoveAt(0);
  53. UploadSeries.RemoveAt(0);
  54.  
  55. Counter--;
  56. }
  57.  
  58. Application.Current.Dispatcher.Invoke(() =>
  59. {
  60. UpdateNetworkInterface();
  61. });
  62. }
  63. });
  64.  
  65. DataContext = this;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement