Question

In ASP.NET, I have to call a reporting service which has the following semantics: 1. create a report 2. check if report is ready for download 3. download the report

My current implementation is that #2 is done in a loop with a Thread.Sleep(1000) so that I poll every second.

I am wondering if there is a better way to accomplish this using ASP.NET 4.5 Async Methods.

Was it helpful?

Solution 2

If you want to poll using async then use Task.Delay instead of Thread.Sleep:

while (await proxy.PollServer())
{
    await Task.Delay(1000);
}

return await proxy.DownloadReport();

You could, as mentioned, flip your architecture so the server will notify the clients upon completion using SignalR:

OTHER TIPS

I would read about:

WCF Duplex

SignalR

And check what suits you the most(based on your clients and other considerations regarding your application).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top