本文整理匯總了C#中StackExchange.Redis.ConnectionMultiplexer.OnInternalError方法的典型用法代碼示例。如果您正苦於以下問題:C# ConnectionMultiplexer.OnInternalError方法的具體用法?C# ConnectionMultiplexer.OnInternalError怎麽用?C# ConnectionMultiplexer.OnInternalError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類StackExchange.Redis.ConnectionMultiplexer
的用法示例。
在下文中一共展示了ConnectionMultiplexer.OnInternalError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ResolveEndPointsAsync
#pragma warning disable 1998 // NET40 is sync, not async, currently
internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, TextWriter log)
{
Dictionary<string, IPAddress> cache = new Dictionary<string, IPAddress>(StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < endpoints.Count; i++)
{
var dns = endpoints[i] as DnsEndPoint;
if (dns != null)
{
try
{
IPAddress ip;
if (dns.Host == ".")
{
endpoints[i] = new IPEndPoint(IPAddress.Loopback, dns.Port);
}
else if (cache.TryGetValue(dns.Host, out ip))
{ // use cache
endpoints[i] = new IPEndPoint(ip, dns.Port);
}
else
{
multiplexer.LogLocked(log, "Using DNS to resolve '{0}'...", dns.Host);
#if NET40
var ips = Dns.GetHostAddresses(dns.Host);
#else
var ips = await Dns.GetHostAddressesAsync(dns.Host).ObserveErrors().ForAwait();
#endif
if (ips.Length == 1)
{
ip = ips[0];
multiplexer.LogLocked(log, "'{0}' => {1}", dns.Host, ip);
cache[dns.Host] = ip;
endpoints[i] = new IPEndPoint(ip, dns.Port);
}
}
}
catch (Exception ex)
{
multiplexer.OnInternalError(ex);
multiplexer.LogLocked(log, ex.Message);
}
}
}
}