VB.NET - Vb.net Form Refresh,Paint,Load - Asked By silna chandra on 24-Apr-09 01:22 AM


I have a Form Application which displays a progressbar showing status of file contents written.

Whenever the Form Application Runs and any other window is brought on top of it and removed .The Form doesn't repaint. The Form appears to be blank and a message called not responding is shown .

Another problem is The progress bar stops displaying the status of progress.

How to Solve this ?

I need the form to repaint and also reflect the current status....


You can use multThreading for repainting your Form to reflect current status

Kalit Sikka replied to silna chandra on 24-Apr-09 01:56 AM

You need to put progressbar logic in child thread within main thread and keep on refreshing it at particular interval.

public static void ApplyMultiThreading(ProgressBar progressBar1) // use this within main thread


System.Threading.Thread ChildThread =

new System.Threading.Thread(

new System.Threading.ParameterizedThreadStart(ActivateBar));



public static void ActivateBar(Object progress) // For Blinking the progress bar


Timer timer = new Timer();

Label label11 = (Label)label1;

BlinkProgress oProgress = new BlinkProgress(timer , progress);


Try these - [)ia6l0 iii replied to silna chandra on 24-Apr-09 02:06 AM

1. do the process that reports the progress asynchronously. Look at backgroundworker component, and use it ReportProgressChanged event for this purpose.  Yes, this component runs on another thread and not on the same UI thread.So it will be responsive. Look at the snippet below for better understanding.

    Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
        End If
    End Sub

    Private Sub backGroundWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backGroundWorker.DoWork
           'Do that intensive work here.
        Catch ex As System.Excpetion
        End Try
    End Sub

    Private Sub backGroundWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles backGroundWorker.RunWorkerCompleted
    End Sub

    Private Sub backGroundWorker_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles backGroundWorker.ProgressChanged
        progressBar.Value = e.ProgressPercentage
    End Sub

2. Use the DoEvents Method of the System.Windows.Forms.Application class to process messages. Add that call before the progress report message calls.


use the backgroundworker - Ravenet Rasaiyah replied to silna chandra on 24-Apr-09 07:30 AM


Best idea here you need to use the background worker to do with process and update GUI in separate thread

look here


thank you