Using ASP.Net WebAPI, I have a controller with an asynchronous action similar to the following:
[HttpPost]
public async Task<string> DoSomething(string foo)
{
var result = await MyAsynchronousTask(foo);
return result;
}
What this controller does is unimportant. Whats important is that it is awaiting an asynchronous task using the new .net 4.5 async/await support.
Question: How do I tell it to time out after a specified duration? I don't necessarily want to cancel the task, I just want to prevent the caller from hanging on forever. (Although, I would be interested in seeing it both ways.)