I want to write an asynchronous action in ASP.NET MVC 2 that waits up to 5 seconds for an event to occur. If the event occurs then the server responds with a result, otherwise the request times out.
What is the best way to achieve this?
I want to write an asynchronous action in ASP.NET MVC 2 that waits up to 5 seconds for an event to occur. If the event occurs then the server responds with a result, otherwise the request times out.
What is the best way to achieve this?
Use the [AsyncTimeout] attribute. If the asynchronous action hasn't completed within the specified time, a TimeoutException will be thrown. You can use an exception filter (like [HandleError]) to watch for these exceptions and handle them appropriately.