public void InitClients() { Task task = Task.Run(() => { _knownClientUrls = _remoteServer.AskForUpdateClients(); UpdateClients(_knownClientUrls); }); try { task.Wait(TimeSpan.FromMilliseconds(TIMEOUT)); if (task.IsCompleted == false) { throw new TimeoutException("Timeout in initClients"); } } catch (AggregateException e) { DetectDeadServer(); SwitchServer(); InitClients(); } catch (TimeoutException e) { DetectDeadServer(); SwitchServer(); InitClients(); } }