Checkup for internet connection

This commit is contained in:
2024-07-16 11:11:09 +03:00
parent 13900bb3f3
commit 224784031c
2 changed files with 28 additions and 6 deletions

View File

@@ -107,4 +107,21 @@ internal static class OnlineFunctions
using var client = new HttpClient();
return await client.GetStringAsync(url, cancellation);
}
internal static async Task<bool> IsInternetConnected()
{
bool result = false;
try
{
using var client = new HttpClient();
await client.GetStringAsync("https://www.google.com");
result = true;
}
catch
{
result = false;
}
return result;
}
}