public void AddInterface(NetworkInterface adapter)
        {
            if (adapter.NetworkInterfaceType == NetworkInterfaceType.Tunnel || adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback)
            {
                return;
            }
            if (adapter.OperationalStatus == OperationalStatus.Down)
            {
                return;
            }

            bool found = false;

            foreach (var s in _interfaces)
            {
                if (s.name == adapter.Name)
                {
                    found = true;
                }
            }
            if (found == false)
            {
                var inf = new StatNetworkItem(adapter.Name);
                _interfaces.Add(inf);
                sessionID = DateTime.Now.Ticks;
            }

            foreach (var s in _interfaces)
            {
                if (s.name == adapter.Name)
                {
                    if (resetAddresses)
                    {
                        s.address = null;
                        IPInterfaceProperties properties = adapter.GetIPProperties();
                        UnicastIPAddressInformationCollection uniCast = properties.UnicastAddresses;
                        foreach (UnicastIPAddressInformation uni in uniCast)
                        {
                            var address = uni.Address.ToString();
                            if (address.Contains("127."))
                            {
                                continue;
                            }

                            Match match = Regex.Match(address, @"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", RegexOptions.IgnoreCase);
                            if (match.Success)
                            {
                                s.address = address;
                            }
                        }
                    }

                    var ns = new NetworkStatQueue
                    {
                        Upload   = adapter.GetIPv4Statistics().BytesSent,
                        Download = adapter.GetIPv4Statistics().BytesReceived,
                        SampleID = historyIndex
                    };
                    s.historyTotals.Enqueue(ns);
                    s.UpdateBandwidth();
                }
            }
        }
        public void AddInterface(NetworkInterface adapter)
        {
            if (adapter.NetworkInterfaceType == NetworkInterfaceType.Tunnel || adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback)
                return;
            if (adapter.OperationalStatus == OperationalStatus.Down)
                return;

                bool found = false;
                foreach (var s in _interfaces){
                    if (s.name == adapter.Name)
                    {
                        found = true;
                    }
                }
                if(found == false){
                    var inf = new StatNetworkItem(adapter.Name);
                     _interfaces.Add(inf);
                    sessionID = DateTime.Now.Ticks;
                }

                foreach (var s in _interfaces){
                    if(s.name == adapter.Name){
                        if (resetAddresses)
                        {
                            s.address = null;
                            IPInterfaceProperties properties = adapter.GetIPProperties();
                            UnicastIPAddressInformationCollection uniCast = properties.UnicastAddresses;
                            foreach (UnicastIPAddressInformation uni in uniCast)
                            {
                                var address = uni.Address.ToString();
                                if (address.Contains("127."))
                                    continue;

                                Match match = Regex.Match(address, @"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", RegexOptions.IgnoreCase);
                                if (match.Success)
                                {
                                    s.address = address;
                                }
                            }
                        }

                         var ns = new NetworkStatQueue
                         {
                             Upload = adapter.GetIPv4Statistics().BytesSent,
                             Download = adapter.GetIPv4Statistics().BytesReceived,
                             SampleID = historyIndex
                         };
                        s.historyTotals.Enqueue(ns);
                        s.UpdateBandwidth();
                    }
                }
        }