Since you're already await
ing the response from the calling code I'm assuming that you mean that you want the lexical flow to appear synchronous, rather than synchronously blocking the calling thread. If that's correct then you can just move the response handling outside of the ContinueWith
callback:
bool _break = false;
int pageNo = 1;
do
{
string url = baseAddress + $"/api/v7/labels?page={pageNo}&limit=1000";
HttpResponseMessage response = await _httpClient.GetAsync(url);
_break = response.IsSuccessStatusCode;
if (response.IsSuccessStatusCode)
{
iStatusCode = (int)response.StatusCode;
string _res = response.Content.ReadAsStringAsync().Result;
if (!string.IsNullOrEmpty(_res))
{
// do some processes
}
}
pageNo++;
} while (!_break);