Add Windows desktop version
This commit is contained in:
34
windows/StreamPlayer.Desktop/Services/DnsHelper.cs
Normal file
34
windows/StreamPlayer.Desktop/Services/DnsHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StreamPlayer.Desktop.Services;
|
||||
|
||||
public static class DnsHelper
|
||||
{
|
||||
private static readonly string[] DomainsToPrefetch =
|
||||
{
|
||||
"streamtpmedia.com",
|
||||
"google.com",
|
||||
"doubleclick.net"
|
||||
};
|
||||
|
||||
public static void WarmUp()
|
||||
{
|
||||
ServicePointManager.DnsRefreshTimeout = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
foreach (var domain in DomainsToPrefetch)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Dns.GetHostAddressesAsync(domain).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore individual failures, this is best-effort caching.
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user