progress bar RRS feed

All replies

  • Hi,

    Here is a simple sample for your reference.


    Public Class ProgressDialog
        Public Sub UpdateProgress(ByVal progress As Integer)
            If ProgressBar1.InvokeRequired Then
                ProgressBar1.BeginInvoke(New Action(Sub() ProgressBar1.Value = progress))
                ProgressBar1.Value = progress
            End If
        End Sub
    End Class


    Imports System.Threading
    Public Class Form1
        Private isProcessRunning As Boolean = False
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If isProcessRunning Then
                MessageBox.Show("A process is already running.")
            End If
            Dim progressDialog As ProgressDialog = New ProgressDialog()
            Dim backgroundThread As Thread = New Thread(New ThreadStart(Sub()
                                                                            isProcessRunning = True
                                                                            For n As Integer = 0 To 100 - 1
                                                                            If progressDialog.InvokeRequired Then progressDialog.BeginInvoke(New Action(Sub() progressDialog.Close()))
                                                                            isProcessRunning = False
                                                                        End Sub))
            Dim form2 As Form2 = New Form2()
        End Sub
    End Class

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, May 28, 2018 8:49 AM
  • how to stop the progress bar then after show a new form?


    Your question makes no sense at all. Show your code.

    What does 'stop the progress bar' mean? That infers you have code to increment it in the first place. Show that code.

    Regards Les, Livingston, Scotland

    Monday, May 28, 2018 3:02 PM
  • A progress bar is always stopped. It moves only when something else tells it to move. So you need to show the code that causes it to move or at least describe it. That is what Les Livingston (leshay) is trying to say.

    Sam Hobbs

    Monday, May 28, 2018 8:22 PM
  • When you quit updating the ProgressBar, for whatever reason you update it, then show a new Form.

    La vida loca

    Tuesday, May 29, 2018 12:03 AM