im pretty new to task and async and i get confused on how to cancel the await on var statuss if its taking too long if the ping is successful its instant but if its not itll ping it for about 10 seconds which is not practical when i want to sort through the list as fast as possible
public async void GetServersV2(List<string> ls)
{
for (int i = 0; i < ls.Count; i++)
{
IMinecraftPinger pinger = new MinecraftPinger(ls[i], (short)port);
try
{
var statuss = await pinger.PingAsync();
Console.WriteLineFormatted($"Server: " + ls[i] + " is {0} | {3} online is " + statuss.Players.Online + "/" + statuss.Players.Max + " | " + "{4} is: " + statuss.Version.Name, Color.White, status);
}
catch
{
Console.WriteLineFormatted("Server: " + ls[i] + " is {1}", Color.White, status);
}
}
}