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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:41:26+00:00 2026-06-18T04:41:26+00:00

Please see the following code: foreach(string url in urls) { //Method that will process

  • 0

Please see the following code:

foreach(string url in urls)
{
  //Method that will process url ProcessUrl(url)
  //Add eached proccessed url to a treelist
}

ProcessUrl method have HttpWebRequest and HttpWebResponse so sometime it takes a nudge and if there were many links it will take time which will hang my program.

I can’t actually suggest a solution of think of one, because i may based it on something wrong so what i want is to make this code runs while i can operate 100% in my program without any crashes or hangs, and that each newly processed link will be inserted to the treelist without any lag.

  • 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-18T04:41:27+00:00Added an answer on June 18, 2026 at 4:41 am

    If you want to perform a long-running operation in the background and pass the results of the operation back to the UI as they become available, while at the same time the UI stays responsive, then it’s straightforward to use BackgroundWorker here.

        void BeginExpensiveOperation()
        {
            var worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.DoWork += ExpensiveWork;
            worker.ProgressChanged += WorkerOnProgressChanged;
    
            List<string> urls = new List<string> { "http://google.com" };
            worker.RunWorkerAsync(urls);
        }
    
        // runs in a worker thread
        void ExpensiveWork(object sender, DoWorkEventArgs e)
        {
            var worker = (BackgroundWorker)sender;
            var urls = (List<string>) e.Argument;
            foreach (var url in urls)
            {
                //TODO: do your work here synchronously
                var result = new WebClient().DownloadString(url);
    
                //TODO: pass the result in the userState argumetn of ReportProgress
                worker.ReportProgress(0, result); // will raise worker.ProgressChanged on the UI thread
            }
        }
    
        private void WorkerOnProgressChanged(object sender, ProgressChangedEventArgs progressChangedEventArgs)
        {
            //this executes on the UI thread
            var value = progressChangedEventArgs.UserState;
            //TODO: use result of computation to add it to the UI
            panel.Children.Add(new TextBlock {Text = value.ToString()});
        }
    

    Fill in your problem-specific code in the //TODO: placeholders and call BeginExpensiveOperation() to start the operation asynchronously.

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

Sidebar

Related Questions

Please see the following code: List list = Collections.synchronizedList(new ArrayList()); // ... synchronized (list)
How do we update a textbox on ticking checkboxes? Please see the following code,
Please see the following code: public void UpdateChildPagesReWrittenUrl(int parentPageId) { var childPageList = db.PcPages.Where(m
Please see my following code snippet. @Transactional public void saveMembersService(List<Member> list1, List<Member> list2) {
Please see the following code: NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@test.pdf]; NSData *myData = [NSData
I'm a green hand in Shell. Please see my following code. How to make
folks please see following code : #include <gio/gio.h> #include <sys/socket.h> //socket(); #include <netinet/in.h> //sockaddr_in
Please see the following code: def viewDidLoad super self.view.translatesAutoresizingMaskIntoConstraints = false self.view.backgroundColor = UIColor.whiteColor
Please see the following example code, which is in a file, say classattr.py class
Please see the following t-sql code DECLARE @iError INT EXEC('select * from sysobj') SELECT

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.