none
progress bar RRS feed

All replies

  • Hi,

    Here is a simple sample for your reference.

    #ProgressDialog

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

    #Form1

    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.")
                Return
            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
                                                                                Thread.Sleep(50)
                                                                                progressDialog.UpdateProgress(n)
                                                                            Next
                                                                            If progressDialog.InvokeRequired Then progressDialog.BeginInvoke(New Action(Sub() progressDialog.Close()))
                                                                            isProcessRunning = False
                                                                        End Sub))
            backgroundThread.Start()
            progressDialog.ShowDialog()
            Dim form2 As Form2 = New Form2()
            form2.Show()
        End Sub
    
    
    End Class
    


    Best regards,

    Zhanglong


    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 MSDNFSF@microsoft.com.

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

    Hi

    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
    SimpleSamples.Info

    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