public static async void InitializeConnection() { while (true) { try { _connection.ConfigureClient(); while (true) { try { _connection.ReceiveInformation((response, command) => { // Detect command command.UseCommand(response); }); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: {0}", ex.Message); Thread.Sleep(_environmentConfiguration.RetryIntervalConnection); break; } } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: {0}", ex.Message); } } }