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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:27:12+00:00 2026-05-18T04:27:12+00:00

private void Form1_Load(object sender, System.EventArgs e) { StartToFillTree(); } private void StartToFillTree( ) {

  • 0
private void Form1_Load(object sender, System.EventArgs e)
{
    StartToFillTree();
}

private void StartToFillTree( )
{
    try
    {
        tvFolders.Nodes.Clear();
        tvFolders.Nodes.Add( new TreeNode("Loading", -1, -1) );

        Thread explorerThread = new Thread( new ThreadStart( FillTreeInAnotherThread ) );
        explorerThread.Start();
    }
    catch (Exception exc)
    {
        //Do the catch
    }
}

private void FillTreeInAnotherThread()
{
    try
    {
        CreateTree(this.tvFolders);
    }
    catch (Exception exc)
    {
        //Do the catch
    }
}


public void ClearTreeview( TreeView tv ) 
{
    tv.Nodes.Clear();
}

public void AddNodeToTreeview( TreeView tv, TreeNode node ) 
{
    tv.Nodes.Add( node );
}

public void CreateTree(TreeView treeView)
{
    try
    {
        TreeNode hoofdNode = new TreeNode( "NodeNam", 0, 0);
        AddDrivesToHoofdNode(hoofdNode); //This method takes 1 ms

        //This part takes 905 milliseconds if I can believe my profiler !!?? -----
        if( treeView.InvokeRequired )
        {
            treeView.Invoke( new ClearTreeviewDelegate( this.ClearTreeview ), new object[] { treeView } );
            treeView.Invoke( new AddNodeToTreeviewDelegate( this.AddNodeToTreeview ), new object[] { treeView, hoofdNode } );
        }
        else
        {
            treeView.Nodes.Clear();
            treeView.Nodes.Add(hoofdNode);
        }
        //End of 900ms part ?? -----


        AddFavorieteFolders(treeView);//This method takes 1 ms

    }
    catch (Exception ex)
    {
        //Do some catching
    }
}
  • 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-18T04:27:12+00:00Added an answer on May 18, 2026 at 4:27 am

    First of all, why are you using threads for something that easy? Looks a bit over-designed. But you are maybe not showing us everything?

    Also wrap the TreeView modifications with:

    treeView.BeginUpdate();
    // modify the tree here.
    treeView.EndUpdate();
    

    To get better performance.

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

Sidebar

Related Questions

private void Form1_Load(object sender, EventArgs e) { GetDataTable(@C:\Documents and Settings\agordon\Desktop\ACTIVITYEX.csv); } public System.Data.DataTable GetDataTable(string
private void Form1_Load(object sender, EventArgs e) { GetDataTable(@C:\Documents and Settings\agordon\Desktop\ACTIVITYEX.log); } public System.Data.DataTable GetDataTable(string
I am using this code: private void Form1_Load(object sender, EventArgs e) { } private
I use two System.Windows.Forms.Timer objects in my project as below. private void Form1_Load(object sender,
I have loaded the files to combo box... private void Form1_Load(object sender, EventArgs e)
public class Form1 : System.Windows.Forms.Form { private void eachCornerPix (object sender, PaintEventArgs e, out
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i <
private void SaveAsPicture_Click(object sender, RoutedEventArgs e) { WriteableBitmap bmp = new WriteableBitmap(MyUIElement, null); var
I get an error from the following code: int dreamX[]; private void Form1_Load(object sender,
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (MessageBox.Show(this,

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.