Я думаю, вы плохо понимаете, о чем я просил. Я получаю время и все остальное очень хорошо. Проблема не в этом!

ользую этот код, но когда я останавливаю процесс, он не получает статистику ping:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "ping";
p.StartInfo.Arguments = "-c " + count + " -i " + interval + " -s " + buffer + " -W " + timeout + " " + address;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;

string readData = "";

DateTime dt = DateTime.Now.AddSeconds(5);
if (p.Start())
{
    Scanner scanner = new Scanner(p.StandardOutput.BaseStream);

    while (scanner.HasNextLine)
    {
        readData =  scanner.NextLine().ToString();
        Console.WriteLine(readData.ToString());

        if (!string.IsNullOrEmpty(readData) && !readData.StartsWith("---"))
        {
            Match M = Regex.Match(readData, @"^[\d]+ bytes from ([^:]+): [^ ]+ ttl=([\d]+) time=([^ ]+) ms");

            if (M != null && M.Success)
            {
                string IP = M.Groups[1].Value;
                string TTL = M.Groups[2].Value;
                string timeStr = M.Groups[3].Value;

                Console.WriteLine(String.Format("Ping to {0} took {2} ms with a ttl of {1}", IP, TTL, timeStr));
                // Parsing the timeStr will work the same way as above
               if(dt > DateTime.Now)
               {
                   p.StandartInput.Write("\x3");
                }
            }
            else
            {
                Match M1 = Regex.Match(readData, @"^rtt [^0-9]*([\d][^\/]+)\/([^\/]+)\/([^\/]+)\/([^ ]+) ms$");

                if (M1 != null && M1.Success)
                {
                    float avgPingTime = 0;
                    float maxPingTime = 0;
                    float minPingTime = 0;

                    string minPingString = M1.Groups[1].Value;
                    string avgPingString = M1.Groups[2].Value;
                    string maxPingString = M1.Groups[3].Value;

                    // Now parse that value
                    float.TryParse(minPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out minPingTime);
                    float.TryParse(avgPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out avgPingTime);
                    float.TryParse(maxPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out maxPingTime);

                    Console.WriteLine(String.Format("Min Time : {0} , AVG {2} ms, Max Time {1}", minPingTime, maxPingTime, avgPingTime));
                }
            }
        }
    }
}

Без использования

if(dt > DateTime.Now)
{
     p.StandartInput.Write("\x3");
}

результат отображается так:

64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=13.9 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=46 time=13.9 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=46 time=13.9 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 3016ms
rtt min/avg/max/mdev = 13.910/13.926/13.951/0.010 ms

но если я остановлюping с помощьюp.StandartInput.Write("\x3"); это никогда не идет кstatistics часть это висит напоследовательность 1 : 64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=13.9 ms и не продолжайте читать, как показатьstatistics после остановкиping процесс ?

другими словами, моя проблема в том, когда пользователь хочет остановитьping он должен отображатьstatistics в течение определенного времени, что он был использован для пинга ...

ОБНОВИТЬ

Я реализовалp.StandartInput.Write("/x3"); и он прерывает процесс проверки связи, но не отображает статистику и просто висит там.

Ответы на вопрос(1)

Ваш ответ на вопрос