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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:38:44+00:00 2026-05-28T02:38:44+00:00

When doing a webrequest, or any other long running task, I should do it

  • 0

When doing a webrequest, or any other long running task, I should do it in a separate thread (let’s call this thread B) so as not to block the UI. But what’s the standard way to take action on the results once the task completes?

I’ve come up with these options so far:

1) Set up a custom event that fires in thread B when the request completes and that the main thread listen for and handles properly.

2) When the request completes make a InvokeOnMainThread call from thread B.

3) Pass along a reference to the ViewController when starting thread B. And then when the web request completes take whatever action is needed on the viewcontroller in thread B itself.

  • 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-28T02:38:45+00:00Added an answer on May 28, 2026 at 2:38 am

    I use the ThreadPool to carry out these requests. This has the advantage that the runtime automatically adds and removes threads based on their usage and you do not have to manage their life cycle:

     class MyViewController : UIViewController {
         void PlusOne (string url, string username)
         {
              ThreadPool.QueueUserWorkItem (delegate {
                  var wc = new WebClient ();
                  wc.UploadString (url, "+1");
                  BeginInvokeOnMainThread (delegate { PlusOneDone (username); });
    
    
         void PlusOneDone (string username)
         {
               Console.WriteLine ("Plus one completed for {0}", username);
         }
     }
    

    In this scenario, I use a couple of anonymous methods, by using nested anonymous methods (or lambdas), you can easily propagate the parameters (in this case “username”) from the original thread that calls PlusOne” to the callback m

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

Sidebar

Related Questions

Let's say I have a web request: WebRequest webRequest = WebRequest.Create(Url); webRequest.BeginGetResponse(this.RespCallback, webRequest); Now
When doing TDD , how to tell that's enough tests for this class /
I want to create a file with a .aspx extension(or any other extension) completely
I'm doing https web requests in silverlight using WebRequest/WebResponse framework classes. Problem is: I
i searched a lot for an answer to this question but i did not
I searched SO and google and saw only problems while doing this, unfortunately for
Okay I tried asking this question yesterday but i'm not sure if I gave
Doing odd/even styling with jQuery is pretty easy: $(function() { $(.oddeven tbody tr:odd).addClass(odd); $(.oddeven
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing my first SL4 MVVM RIA based application and i ran into the following

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.