Controls cannot be made visible after a thread run

Discussion in 'C#' started by Leo, Nov 23, 2006.

  1. Leo

    Leo New Member

    Joined:
    Nov 10, 2006
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    I have a thread which runs a method. In that method i am making use of progressbar but after that method gets over that progress bar becomes invisible and eventhough i make them visible they does nto become visible.
    Code:
     private void StartLoadProcess(string filePath) 
        { 
          try 
          { 
            _cancelButton.Visible = false; 
             Thread workerThread = new Thread(DoUploadProcess); 
            
            // Start the [URL=http://www.go4expert.com/articles/worker-threads-mfc-t3197/]worker thread[/URL]. 
            workerThread.Start(); 
            while (workerThread.ThreadState.ToString().ToLower() == "running") 
            { 
              _cancelButton.Visible = true; // making Button Visible 
              _cancelButton.Refresh(); // Invalidating it 
              _cancelButton.Focus(); // setting the focus 
              Application.DoEvents(); 
            } 
            workerThread.Abort(); 
    
            this._progressbarLabel.Visible = true; -------------------This code will not work at all 
            this._statusProgressBar.Visible = true; -------------------This code will not work at all 
             
            _cancelButton.Visible = true; 
             this.PrepareStatusTree(); 
    
            //Enable the timer to load the tree until the load is completed 
            this._timer.Enabled = true; 
            this._loadFileStatus.Visible = false; 
          }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    That should not be happening. Have you seen if it causes an exception of type thread unsafe operation.

    Also do use the code block for putting code in post.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice