I'm having the following simple Web API controller:
The expected behavior should be letting the AsyncTimer running in parallel with the Get method, any ideas?
Thanks.
public class MyController : ApiController
{
public MyController()
{
AsyncTimer();
}
[HttpGet]
public string Get()
{
return "asdf";
}
private async void AsyncTimer()
{
await Task.Delay(10000);
System.Diagnostics.Debug.WriteLine("Async timer...");
}
}
It seems the get request will not return until my AsyncTimer has finished after 10 seconds. But since the return value of AsyncTimer is void, the constructor returns immediately after calling AsyncTimer. The expected behavior should be letting the AsyncTimer running in parallel with the Get method, any ideas?
Thanks.