How can I make repetitive calls to a URL by time intervals till I get successful result or timeout?
I upload a file to an API and it sends me a URL to let me check if my file is processed successfully. I want to make it so this url is checked in the server until the pending status is changed. There are successful, failed and pending statuses. I want to keep the user wait until the result is either fail or success.
[HttpGet]
public async Task<ActionResult> Get()
{
...
response = await client.GetAsync(other_api_url);
if(response.IsSuccessStatusCode)
{
string result = response.Content.ReadAsStringAsync().Result;
dynamic output = JsonConvert.DeserializeObject<dynamic>(result);
statusUrl = output.url_to_check_status;
//make a call to statusUrl check if content is ready
//get result and parse it
...
status = output.status;
if(status == "SUCCESS")
{
//good path
return Ok();
}
else
{
//make another call after n seconds to check again
}
}
return NotFound();
}
repetitive calls to a URL till I get successful result or timeout??- But this is what you're asking??.Resultrisks deadlocks