// helper method for beacon sending with retries private StatusResponse SendBeaconRequest(IHTTPClient httpClient, byte[] beaconData, int numRetries) { StatusResponse response = null; var retry = 0; var retrySleepMillis = INITIAL_RETRY_SLEEP_TIME_MILLISECONDS; while (true) { response = httpClient.SendBeaconRequest(clientIPAddress, beaconData); if (response != null || (retry >= numRetries)) { // success OR max retry count reached break; } timingProvider.Sleep(retrySleepMillis); retrySleepMillis *= 2; retry++; } return(response); }