I understand what is waiting for the task to complete (expected). But I'm confused by what it really means.
Code that doesn't work :
public async override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
if (actionExecutedContext.Response.Content != null)
{
var responseContent = await actionExecutedContext.Response.Content.ReadAsStringAsync();
DoSomething(responseContent);
}
}
The code works :
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
if (actionExecutedContext.Response.Content != null)
{
var responseContent = actionExecutedContext.Response.Content.ReadAsStringAsync().ContinueWith(
task =>
{
DoSomething(task.Result);
});
}
}
Obviously, the error message The asynchronous module or handler has completed while the asynchronous operation is still waiting. tells me that there were no expectations of the completion of the asynchronous call, but instead the "main" thread continued. I was expecting the stream to continue, but not in the current method. I thought the thread would return to the asp.net stack, do some other work, and return after the asyncOperation () operation was completed.
(, -) - . , IActionFilterAttribute -. -, , , .
-, , ? , .