private void HandleRefreshedTunnels(List <CnCNetTunnel> tunnels) { if (tunnels.Count > 0) { Tunnels = tunnels; } TunnelsRefreshed?.Invoke(this, EventArgs.Empty); if (UserINISettings.Instance.PingUnofficialCnCNetTunnels) { PingUnofficialTunnelsAsync(Tunnels); } }
private void HandleRefreshedTunnels(List <CnCNetTunnel> tunnels) { if (tunnels.Count > 0) { Tunnels = tunnels; } TunnelsRefreshed?.Invoke(this, EventArgs.Empty); Task[] pingTasks = new Task[Tunnels.Count]; for (int i = 0; i < Tunnels.Count; i++) { if (UserINISettings.Instance.PingUnofficialCnCNetTunnels || Tunnels[i].Official || Tunnels[i].Recommended) { pingTasks[i] = PingListTunnelAsync(i); } } if (CurrentTunnel != null) { var updatedTunnel = Tunnels.Find(t => t.Address == CurrentTunnel.Address && t.Port == CurrentTunnel.Port); if (updatedTunnel != null) { // don't re-ping if the tunnel still exists in list, just update the tunnel instance and // fire the event handler (the tunnel was already pinged when traversing the tunnel list) CurrentTunnel = updatedTunnel; DoCurrentTunnelPinged(); } else { // tunnel is not in the list anymore so it's not updated with a list instance and pinged PingCurrentTunnelAsync(); } } }