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 8494319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:16:02+00:00 2026-06-10T23:16:02+00:00

Possible Duplicate: Execute a WebRequest in a Background thread while UI Thread is blocked

  • 0

Possible Duplicate:
Execute a WebRequest in a Background thread while UI Thread is blocked

Check out this code:

Thread t = new Thread((a) =>
    {
        var client = new WebClient();

        client.DownloadStringAsync(new Uri("http://www.google.com"));

        bool pointB = true;
    });

t.Start();
t.Join(10000);

When this is run on the UI thread in Silverlight, even though DownloadStringAsync() is called quickly, pointB will not be reached until after the Join() times out. This means DownloadStringAsync() must somehow require the UI thread to do its work. Note: this has nothing to do with the callback to DownloadString. I know that WebClient’s callbacks happen on the UI thread (see here: Silverlight Background Thread using WebClient).

The behavior of my code seems to indicate that the async invoke method itself (DownloadStringAsync()) also requires the UI thread. Is that right? And if so, why? I also want to note this same behavior is exhibited when using HttpWebRequest.BeginGetResponse()

Edit: to make things crystal clear, the order of operations I see when I step through this code is

  1. t.Start()
  2. t.Join(10000);
  3. var client = new WebClient();
  4. client.DownloadStringAsync(new Uri(“http://www.google.com“));
  5. (… Join() timeout)
  6. bool pointB = true;
  • 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-10T23:16:03+00:00Added an answer on June 10, 2026 at 11:16 pm

    Alright, I think I figured out the answer after a little more digging. It does seem indeed that all network code is ultimately run on the UI thread:
    http://nondestructiveme.com/2010/11/23/silverlight-and-networking-the-ui-thread/

    The good news is it seems Microsoft fixed this “bug”, as you might be justified in calling it, in Silverlight 5:
    http://msdn.microsoft.com/en-us/library/gg986857(VS.95).aspx

    (At the bottom of the page under Performance Improvements:
    “Reduced network latency by using a background thread for networking. This is helpful for scenarios that use client HTTP web requests.”)

    I’ll edit this answer once I test my code on Silverlight 5 to see if it indeed fixed the issue.

    Edit: Built against Silverlight 5 and I’m still having the same problem. I think it’s time for me to give up trying to block the UI thread at all…

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

Sidebar

Related Questions

Possible Duplicate: Java REPL shell Hey, Is there any way to execute Java code
Possible Duplicate: How can I execute a block of code exactly once in PHP?
Possible Duplicate: Java code to execute a .sh file I write the code in
Possible Duplicate: Exception in thread “main” java.lang.NoSuchMethodError: main I am fairly new to Java,
Possible Duplicate: php execute a background process how can I achieve a task that
Possible Duplicate: JavaScript alert not working in Firefox 6 I often execute Javascript code
Possible Duplicate: ACRA with android: How to execute code before crash is reported I
Possible Duplicate: Choose order to execute JUnit tests I am writing a JUnit test.
Possible Duplicate: .htaccess rewrite image file to php script How can I execute a
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web

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.