开发者

WCF - Composite IAsyncResult

开发者 https://www.devze.com 2023-01-08 11:35 出处:网络
I have a开发者_StackOverflow WCF service that I want to use the async pattern on as it mainly calls a series of web services and then processes the results once all of the web service calls have retur

I have a开发者_StackOverflow WCF service that I want to use the async pattern on as it mainly calls a series of web services and then processes the results once all of the web service calls have returned.

However, the async pattern in WCF only supports a single IAsyncResult being returned in the BeginXXX method.

I was wondering if anyone had any experience of creating a composite IAsyncResult that could signal once all the web services have returned, or have any other ideas to handle the problem?


I think basically you'll need to create your own custom IAsyncResult implementation as well as doing some serious book-keeping around your requests. I'm assuming you'll want to fire your internal requests in parallel and then wait until all are done before returning, right?

If so, then what I'd do is create a custom IAsyncResult, while internally keeping track of each of the IAsyncResults associated with each internal call, then only consider my custom IAsyncResult done (which implies both signaling it's wait handle, as well as firing any callbacks) when all the internal requests are done.

0

精彩评论

暂无评论...
验证码 换一张
取 消