Exemplo n.º 1
0
 /// <summary>
 /// Запуск проверки
 /// </summary>
 /// <param name="functionToExec">обновить состочние на консоле</param>
 public void GoCheck(Action functionToExec)
 {
     foreach (KeyValuePair <string, IPAddressCheck> entry in addrsDict)
     {
         Task task = new Task(() =>
         {
             Resolv rs = new Resolv();
             rs.Traceroute(functionToExec, entry.Value);
         });
         task.Start();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// добавить хост и IP в словарь и хеш-таблицу
        /// </summary>
        /// <param name="hostName"></param>
        /// <returns></returns>
        public static bool AddHost(string hostName)
        {
            IPAddress ip = Resolv.GetHostEntry(hostName);

            if (ip == null)
            {
                return(false);
            }

            if (!hosts.Contains(hostName))
            {
                hosts.Add(hostName);
                if (!addrsDict.ContainsKey(hostName))
                {
                    addrsDict.Add(hostName, new IPAddressCheck {
                        ipAddress = ip, HostName = hostName
                    });
                    return(true);
                }
            }

            return(false);
        }