Esempio n. 1
0
		// Enable the timer, and add the specified adapter to the monitoredAdapters list
		public void StartMonitoring(NetworkAdapter adapter)
		{
			if (!this._monitoredAdapters.Contains(adapter))
			{
				this._monitoredAdapters.Add(adapter);
				adapter.Init();
			}
			_timer.Enabled	=	true;
		}
Esempio n. 2
0
		/// <summary>
		/// Enumerates network adapters installed on the computer.
		/// </summary>
		private void EnumerateNetworkAdapters()
		{
			PerformanceCounterCategory category	=	new PerformanceCounterCategory("Network Interface");

			foreach (string name in category.GetInstanceNames())
			{
				// This one exists on every computer.
				if (name == "MS TCP Loopback interface")
					continue;
				// Create an instance of NetworkAdapter class, and create performance counters for it.
				NetworkAdapter adapter	=	new NetworkAdapter(name);
				adapter.DlCounter	=	new PerformanceCounter("Network Interface", "Bytes Received/sec", name);
				adapter.UlCounter	=	new PerformanceCounter("Network Interface", "Bytes Sent/sec", name);
				this._adapters.Add(adapter);			// Add it to ArrayList adapter
			}
		}
Esempio n. 3
0
		// Remove the specified adapter from the monitoredAdapters list, and disable the timer if the monitoredAdapters list is empty.
		public void StopMonitoring(NetworkAdapter adapter)
		{
			if (this._monitoredAdapters.Contains(adapter))
				this._monitoredAdapters.Remove(adapter);	
			if(this._monitoredAdapters.Count == 0)
				_timer.Enabled	=	false;
		}