how to make multiple asynchronous web service method calls in the same thread? [modified]
-
Hi, I would like to know how to make multiple asynchronous web service method calls in the same thread? What if the web service method cannot be checked by IAsyncResult status operation statement but just invoking the MethodNameAsync(X,Y,Z). What I think is sleeping the thread shouldn't be the way to handle it because lets assume that 20 of form controls inside the form uses web methods to populate themselves and one of the control's value is used as an argument to call another asynchronous method to populate another control in the form . The problem is I have a few asynchronous call in the same thread and I couldn't figure it out how to create waits between the each asynchronous calls until it gets loaded completely. Is there a way to load all asynchronous methods before the form loads. if you enlighten me about the solution, I would really appreciate it. This is my first Web Service client issue to solve and I have no experience about it. Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Tuesday, May 24, 2011 9:28 AM
-
Hi, I would like to know how to make multiple asynchronous web service method calls in the same thread? What if the web service method cannot be checked by IAsyncResult status operation statement but just invoking the MethodNameAsync(X,Y,Z). What I think is sleeping the thread shouldn't be the way to handle it because lets assume that 20 of form controls inside the form uses web methods to populate themselves and one of the control's value is used as an argument to call another asynchronous method to populate another control in the form . The problem is I have a few asynchronous call in the same thread and I couldn't figure it out how to create waits between the each asynchronous calls until it gets loaded completely. Is there a way to load all asynchronous methods before the form loads. if you enlighten me about the solution, I would really appreciate it. This is my first Web Service client issue to solve and I have no experience about it. Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Tuesday, May 24, 2011 9:28 AM
JUNEYT wrote:
Is there a way to load all asynchronous methods before the form loads.
If the calls are truly asynchronous then there should be some notification of completion (like an event). I use something similar to the DomainContextLoadBatch class found in this article[^]. This class lets you queue up a bunch of asynchronous calls and doesn't notify you until they have all completed. The class as shown is for WCF RIA Services LoadOperation calls, but could easily be modified for other webservice call types. *edit* If you use that class as a guide, please note that as shown the class is NOT thread safe, so if your webservice calls can complete on other threads you'll need to make sure at least the class' single completion handler is thread safe. You shouldn't have to sleep and wait...that negates the whole purpose of asynchronous calls...
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Tuesday, May 24, 2011 12:03 PM