프록시를 핑 (ping)하려고하는데 내 코드로 진행하기 전에 응답을받는 데 걸리는 시간이 얼마나 길지 만 스톱워치는 너무 빠릅니다. 내가 여기서 어디로 잘못 가고 있니?C# 프록시 핑을 기다리는 방법?
private async void idunno()
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
var x = await CanPing2();
Console.WriteLine("is proxy alvie: " + x);
stopWatch.Stop();
int ts = stopWatch.Elapsed.Milliseconds;
Console.WriteLine("RunTime " + ts);
Console.WriteLine("RunTime " + ts2);
}
public async Task<bool> CanPing2()
{
string ip = "170.130.59.107";
Console.WriteLine(ip);
Ping ping = new Ping();
try
{
PingReply reply = await ping.SendPingAsync(ip, 6000);
if (reply == null) return false;
Console.WriteLine("cp2 is alive: " + IPStatus.Success);
return (reply.Status == IPStatus.Success);
}
catch (PingException e)
{
Console.WriteLine("cp2: ex: " + IPStatus.Success);
return false;
}
}
당신은 지금 몇시에 무엇을 기대하고 있습니까? – arbitrarystringofletters
나는 2-600ms를 얻는다. 나는 6000ish를 기대하고있다. – user6793946