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

  • Home
  • SEARCH
  • 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 6600763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:40:00+00:00 2026-05-25T18:40:00+00:00

I want to send multiple asynchronous calls to different web services with silverlight and

  • 0

I want to send multiple asynchronous calls to different web services with silverlight and be able to match the responses to each request.

Lets say i have a list with n items in it. Every item represents a string URL of a web service. So you may have 2 services, but you also may have 7.
Now, i have a GUI and when i press a button, the list with the URLs is iterated and to every service a request is sent. You do not know how many services you might call, so it has to be dynamic.
I have solved the sending part, and i get all the responses, BUT with my solution there is no way to figure out which response refers to which request.

private void startCall(object sender, RoutedEventArgs e) 
{
    var urls = {"http://this.is.the.first/service1", "http://this.is.thesecond/service2", "http://this.is.thethirt/service3"};
          foreach (var item in urls)
            {
                WebClient wc = new WebClient();
                wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

                wc.DownloadStringAsync(new Uri(item));               
            }

void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {

            if (e.Error == null)
            {
                list_ResponseFromServer.Add(e.Result.ToString());
            }
        }

In this example i have 3 services/items in the list. And i also get 3 responses to the handler void wc_DownloadStringCompleted, but i do not know in what order.
Its obvious i want to have

ListRequest(A,B,C,D,E)

ListResponse(A,B,C,D,E)

but i do not know if response A takes much longer than response B,C

so I might get in my ListResponse(B,C,D,A,E) => what is FAIL

I have seen some examples with 2 asynchronous calls, but they were all hardcoded. For every request, response they had several hardcoded methods/handlers.
It would be great if someone could help me to solve this problem with a variable amount of multiple asynchronous calls to different webServices

  • 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-05-25T18:40:01+00:00Added an answer on May 25, 2026 at 6:40 pm

    One approach would be to use a delegate to create a capture like this:-

    private void startCall(object sender, RoutedEventArgs e) 
    {
        var urls = {"http://this.is.the.first/service1", "http://this.is.thesecond/service2", "http://this.is.thethirt/service3"};
        foreach string item in urls)
        {
            Uri uri = new Uri(item);
    
            WebClient wc = new WebClient();
            wc.DownloadStringCompleted += (s, args) =>
            {
                 if (args.Error == null)
                 {
                     // You can use the uri variable to determine which Uri this is a response to.
                     // NOTE: don't use item variable here.
                     list_ResponseFromServer.Add(args.Result);
                 }
            };             
            wc.DownloadStringAsync(new Uri(item));               
        }
     }
    

    Edit: Response to comments

    By one means or another you need a way to corelate a response to the orignating request. The Silverlight API offers no built in mechanism to do that, there is no standard solution. So yes you need to write your own code to relate an asynchronous response to the originating Url if that is important to you. If you prefer to use the original string url then add another string variable inside the foreach code block and assign item to it.

    What it sounds like you are looking for is away to guarantee the order that the responses arrive in to match the order they are generated. The only way to do that is to issue each request only when the previous response has arrived. Whilst that is possible (I’ve written a series of blogs on the subject), I wouldn’t recommend it as solution in this case.

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

Sidebar

Related Questions

I'm using Node.js and I want to send back multiple responses to the client.
How can I send multiple http requests sequentially to a server ? I want
I want to send an image from one android device to one or multiple
I have multiple classes, all of which I want to send an identical message
I want to send 1 message to multiple contact. I searched on that but
I want to send messages to multiple friends in linkedin using python. from docs
I want to send multiple parameters using POST to an asp.net handler. How is
I am implementing PayPal in my Android application and I want to send multiple
I have multiple forms, and I want to send classnames of these HTML form's
I want to send multiple attachments but not declaring them just octet-stream doing it

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.