NetworkAdapter.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //using System.Diagnostics;
  2. //namespace Optimizer
  3. //{
  4. // public class NetworkAdapter
  5. // {
  6. // long _downloadSpeed, _uploadSpeed;
  7. // long _downloadValue, _uploadValue;
  8. // long _downloadValueOld, _uploadValueOld;
  9. // string _name;
  10. // internal PerformanceCounter DownloadCounter, UploadCounter;
  11. // internal NetworkAdapter(string name)
  12. // {
  13. // _name = name;
  14. // }
  15. // internal void Initialize()
  16. // {
  17. // _downloadValueOld = DownloadCounter.NextSample().RawValue;
  18. // _uploadValueOld = UploadCounter.NextSample().RawValue;
  19. // }
  20. // internal void Refresh()
  21. // {
  22. // _downloadValue = DownloadCounter.NextSample().RawValue;
  23. // _uploadValue = UploadCounter.NextSample().RawValue;
  24. // _downloadSpeed = _downloadValue - _downloadValueOld;
  25. // _uploadSpeed = _uploadValue - _uploadValueOld;
  26. // _downloadValueOld = _downloadValue;
  27. // _uploadValueOld = _uploadValue;
  28. // }
  29. // public override string ToString()
  30. // {
  31. // return _name;
  32. // }
  33. // public string Name
  34. // {
  35. // get { return _name; }
  36. // }
  37. // public long DownloadSpeed
  38. // {
  39. // get { return _downloadSpeed; }
  40. // }
  41. // public long UploadSpeed
  42. // {
  43. // get { return _uploadSpeed; }
  44. // }
  45. // public double DownloadSpeedKbps
  46. // {
  47. // get { return this._downloadSpeed / 1024.0; }
  48. // }
  49. // public double UploadSpeedKbps
  50. // {
  51. // get { return this._uploadSpeed / 1024.0; }
  52. // }
  53. // public double DownloadSpeedMbps
  54. // {
  55. // get { return this._downloadSpeed / 1024.0 / 1024.0; }
  56. // }
  57. // public double UploadSpeedMbps
  58. // {
  59. // get { return this._uploadSpeed / 1024.0 / 1024.0; }
  60. // }
  61. // }
  62. //}