/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnPingCompleted(object sender, PingCompletedEventArgs e) { LogHelper.Trace(); ClusterIpState state; switch (e.Reply.Status) { case IPStatus.TimedOut: case IPStatus.TimeExceeded: case IPStatus.TtlExpired: state = ClusterIpState.NotFound; break; default: state = ClusterIpState.Found; break; } lock (_Sync) { if (sender == _Ping1) { _ClusterIp1State = state; } else { _ClusterIp2State = state; } _PingReceivedTime = DateTime.Now; } }
/// <summary> /// /// </summary> /// <param name="async"></param> /// <returns></returns> bool ExistClusterAddresses_old(bool async) { LogHelper.Trace(); if (((DateTime.Now - _PingReceivedTime).TotalMilliseconds > 2000) && (_ClusterIp1State != ClusterIpState.Finding) && (_ClusterIp2State != ClusterIpState.Finding)) { _ClusterIp1State = ClusterIpState.Finding; _ClusterIp2State = ClusterIpState.Finding; _Ping1.SendAsync(_Settings.ClusterIp1, 2000, null); _Ping2.SendAsync(_Settings.ClusterIp2, 2000, null); } if (!async) { while ((_ClusterIp1State == ClusterIpState.Finding) || (_ClusterIp2State == ClusterIpState.Finding)) { System.Threading.Thread.Sleep(500); } } //return ((_ClusterIp1State != ClusterIpState.NotFound) || (_ClusterIp2State != ClusterIpState.NotFound)); return((_ClusterIp1State == ClusterIpState.Found) || (_ClusterIp2State == ClusterIpState.Found)); }