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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:26:24+00:00 2026-05-22T01:26:24+00:00

I am a beginner to C#. I am trying to make a simple program

  • 0

I am a beginner to C#. I am trying to make a simple program that displays the links from a website into a ListBox. Since retrieving the links takes time, my GUI waits till all the links are parsed and ListBox populated before it becomes visible.

I would assume that this is because the InitializeComponent() and my ParseLinks() methods run in the same thread. I would like to know if there is way I could run ParseLinks() after the UI elements are loaded.

    public mainForm()
    {
        InitializeComponent();
        ParseLinks();
    }

I would appreciate any input. Thanks

[Edit]

More info on ParseLinks(): (I am giving the summary since the code is quite extensive)

ParseLinks() gets the links into an arraylist and assigns the arraylist to the ListBox. The whole operation works very well. But I wanted the GUI to be displayed and then the ListBox populated. I am also disabling a Button while at it and also changing a ProgressBar Style to Marquee. Referring to the response I gave below, when I used Backgroundworker, I got multiple cross-thread operation error which I solved by placing the GUI editing code inside one InvokeRequired statement

  • 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-22T01:26:25+00:00Added an answer on May 22, 2026 at 1:26 am

    If you are using WinForms, I suggest using BackgroundWorker. Your form would populate ListBox in a background thread.
    More details here and here.

    [Edit]

    Here is the basic idea:

    public Form1()
    {
        InitializeComponent();
        backgroundWorker1.RunWorkerAsync();
    }
    
    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        for(var i = 0; i < 1000; i++)
        {
            var newElement = BuildMyElement(i);
            backgroundWorker1.ReportProgress(0, newElement);
        }
    }
    
    private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        var newElement = (MyType)e.UserState;
        listBox1.Items.Add(newElement);
    }
    

    Replace backgroundWorker1_DoWork with the code that you use to retrieve URLs.

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

Sidebar

Related Questions

i m trying to make a simple program ( & yes , it is
For quite awhile I have been trying to make a simple game in Java
I am trying to write a C++ program that works like the game 24.
There is very simple task I want to do, that somehow makes the program
I'm trying to make a simple php shopping cart. I don't have any idea
I'm a beginner to Iphone Development :) I am trying to make a button
What I'm trying to do is quite simple but as a beginner I'm getting
I'm a beginner to 3D graphics in general and I'm trying to make a
I am a beginner Android developer and I am trying to make a game
I am a beginner with Selenium, and I am trying a simple case 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.