Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:53:18+00:00 2026-06-01T01:53:18+00:00

Got a question regarding best practices for doing parallel web service calls, in a

  • 0

Got a question regarding best practices for doing parallel web service calls, in a web service. This is for a back up plan in the case another potion of the project is unable to be delivered on time. I’d rather have something that works, even if it’s throw-away, so the end user isn’t interrupted.

Our portal will get a message, split that message into 2 messages, and then do 2 calls to our broker. These need to be on separate threads to lower the timeout.

One solution is to do something similar to (pseudo code):
*Update: Not as efficient as was thought, executes fast but no as fast as calling is asynchronously through a delegate.

XmlNode DNode = GetaGetDemoNodeSomehow();
XmlNode ENode = GetAGetElNodeSomehow();
XmlNode elResponse;
XmlNode demResponse;
Thread dThread = new Thread(delegate
{
    //Web Service Call
    GetDemographics d = new GetDemographics();
    demResponse = d.HIALRequest(DNode);
});
Thread eThread = new Thread(delegate
{
    //Web Service Call
    GetEligibility ge = new GetEligibility();
    elResponse = ge.HIALRequest(ENode);
}); 
dThread.Start();
eThread.Start();
dThread.Join();
eThread.Join();
//combine the resulting XML and return it.
//Maybe throw a bit of logging in to make architecture happy

Another option we thought of is to create a worker class, and pass it the service information and have it execute. This would allow us to have a bit more control over what is going on, but could add additional overhead.

Another option brought up would be 2 asynchronous calls and manage the returns through a flag:
Update:
*This is not as efficient as the updated way I tried. This is 25% slower (running optimized) as the one I have below.

        personRevisedService.GetDemoCompleted += new GetDemoCompletedEventHandler(GetDemo_Completed);                      
        personRevisedService.GetDemoAsync(SomeXML);

The portal service will be called about 50,000 times a day.

I don’t want to gold plate this sucker.

I’m looking for something light weight. The services that are being called on the broker do have time out limits set, and are already heavily logged and audited, so I’m not worried on that part.

This is .NET 2.0 , and as much as I would love to upgrade I can’t right now. So please leave all the goodies of > 2.0 out please.

Update

I decided to call them using a delegate. Because this is a test, I’m calling the same service twice, as the other service is not yet built. It executed on average 20-30% faster than using [WebServiceName]Async(…),

public delegate XmlElement HServiceDelegate(XmlElement xml);


HServiceDelegate del1 = new HServiceDelegate(ws1.HGetDemographics);
HServiceDelegate del2 = new HServiceDelegate(ws2.GetDemographics);

IAsyncResult async1 = del1.BeginInvoke(x1.DocumentElement, callback1, null);
IAsyncResult async2 = del2.BeginInvoke(x2.DocumentElement, callback2, null);

//Not sure if this is the most efficient
while (!async1.IsCompleted && !async2.IsCompleted)
{
    System.Threading.Thread.Sleep(5);
}



void callback1(IAsyncResult result)
{
    AsyncResult r = (System.Runtime.Remoting.Messaging.AsyncResult)result;
    HServiceDelegate caller = (HServiceDelegate)r.AsyncDelegate;
    r1 = caller.EndInvoke(result);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:53:19+00:00Added an answer on June 1, 2026 at 1:53 am

    Your approach is very inefficient, and may very well cause more harm than good. You’ll be tying up a worker thread until both calls are complete, and you’ll be producing many full threads, for no good reason.

    Look into making your service asynchronous, and using the Begin/End* methods of your web references.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got another question regarding to basic Android programming: How can I access the
While reading the answers to this question I got a doubt regarding the default
I've got a quick question regarding the use of repositories. But the best way
I have got a question regarding suprepositories. Our project is set up like this:
I've got a question regarding a SQL-select-query: The table contains several columns, one of
Reading over the responses to this question Disadvantages of Test Driven Development? I got
Thanks in Advance for reading and answer this question. I got button in asp
This question got me thinking about bare strings. When PHP sees a string that's
Got a (hopefully small) question regarding SVN and checking out repos. Basically I see
So this question is regarding the .Net IAsyncResult design pattern and the necessity of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.