35 lines
841 B
C#
35 lines
841 B
C#
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.
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|