I have a long running process that is called via a Nancy Module Get method. Rather than have the browser hang while the process runs I would like this call to be asynchronou
I am new to the async / await features of C#5 but I feel sure these are meant for just this kind of task.
No. async
/await
are intended to make asynchronous programming easy within the context of a single process. They do not change the nature of HTTP communications.
When you use await
on an ASP.NET server (in the context of an HTTP request), you are returning the ASP.NET thread to the thread pool. However, ASP.NET is aware that the HTTP request has not completed, so it does not complete the response to the client (browser).
This is by design.
You'll need to use AJAX, SignalR, or some other solution in order to do what you want.