문제

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.

도움이 되었습니까?

해결책 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:

다른 팁

I would read about:

WCF Duplex

SignalR

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top