Skip to content

Instantly share code, notes, and snippets.

@gled4er
Created November 28, 2017 05:03
Show Gist options
  • Save gled4er/d22827fb61baac64e96ce7e6b1924d1b to your computer and use it in GitHub Desktop.
Save gled4er/d22827fb61baac64e96ce7e6b1924d1b to your computer and use it in GitHub Desktop.
Sync Response Service
public async Task<object> ProvideOutput(OrchestrationClientResponse clientResponse, ExecutionDetails executionDetails, TraceWriter log)
{
object result = null;
using (var httpClient = new HttpClient())
{
for (var i = 0; i < executionDetails.Iterations; i++)
{
Thread.Sleep(executionDetails.IterationPeriod);
string statusCheck;
try
{
statusCheck = await httpClient.GetStringAsync(clientResponse.StatusQueryGetUri);
}
catch (Exception e)
{
// log the exception
log.Error(e.Message);
continue;
}
var status = JsonConvert.DeserializeObject<StatusResponse>(statusCheck);
if (status.RuntimeStatus != "Completed") { continue; }
result = status.Output;
break;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment