Monday, November 25, 2013

Return All Calls in Sequence After Async

I modified the code as shown below, and yet again, found it does NOT work. I added the ContinueWith, thinking it would do the


Post Processing AFTER SendRequestAsync returns data. The problem is that after executing QueryAsync(), the status of httpResponseTask = WaitingForActivation.


So here's the question: How do I activate httpResponseTask?????????????????????



public ProcessedResponse Query()
{
ProcessedResponse processedResponse = null;

HttpResponseMessage httpResponseTask = QueryAsync();

// Need line here to Activate httpResponseTask!!!!!!!!!!!!!!!!!!!!

await httpResponseTask.ContinueWith(t =>
{
processedResponse = MyPostProcessing(t.Result);
)};
return processedResponse
}

async HttpResponseMessage QueryAsync()
{
...
HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);

return httpResponseMessage
}






Randy


No comments:

Post a Comment