Ann L.
Ann L.

Reputation: 13965

Running multiple reports from SSRS simultaneously through async web service calls

I have a small batch program whose job is to call the SSRS 2008 web service with a variety of parameters and route the resulting reports. (For various reasons, SSRS subscriptions wouldn't work in this environment.)

Currently it uses the Parallel class to run multiple reports at one time and take advantage of the report server's ability to handle multiple simultaneous requests. But I've read (in the comments here) that this isn't the way to go: that since what we're spreading across multiple threads on the client is I/O rather than processing load, the thing to do would be to make async calls to the web service and wait for the results.

VS 2010 generated a web service client for me that includes xxxxAsync methods and xxxxCompleted events. It's relatively straightforward to set up a couple of methods to call, one that calls the web service Render2Async method and the other which handles Render2AsyncCompleted.

But now I'm in unfamiliar territory. First, this breaks all my tests. How does one test an async web service: by writing async tests? Does my app need to fire off its own EventCompleted message so that the test can know that the app is finished with a given report and the test can continue?

Second, how can I prevent the app from terminating prematurely? I've read about WaitHandle and its methods, but WaitHandle.WaitAll assumes that you have access to the wait handles from all your tasks, and none are exposed by the web service client. The Render2Async method doesn't have a return value.

Many thanks.

Upvotes: 0

Views: 2368

Answers (1)

Scott Willeke
Scott Willeke

Reputation: 9335

NUnit supports the delayed constraint 'After' that allows you to poll on a test periodically in cases like this. Examples of NUnit After here and here. It is not technically comprehensive as it is a simplistic polling solution, but it is easy to use and would work in some simple cases.

Microsoft's silverlight test framework has a bit more comprehensive support using the EnqueueXXX methods as shown in the articles here and here.

Finally, "manual" way of unit test using ManualResetEvent is also shown in this article.

Upvotes: 1

Related Questions