VB 中添加進度條

加載時如果沒有進度條會給人舒服的感覺,以下是進度條的代碼,在加載函數前StartProgressBar(),執行完之後EndProgressBar()

#Region "進度條"
    '''==================進度條Begin========================================================================
    Private ProgressForSwitchFormT1 As ProgressForSwitchForm
    Private ThreadT2 As Thread

    Private Sub ShowProgressForSwitchForm(ByVal ProgressFormT1 As ProgressForSwitchForm)
        Application.Run(ProgressFormT1)
    End Sub

    Private Sub EndProgressForm(ByVal ProgressFormT1 As ProgressForSwitchForm)
        Try
            ProgressFormT1.Close()
        Catch ex As Exception
        End Try
    End Sub

    ' 開始進度條
    Public Sub StartProgressBar()
        ProgressForSwitchFormT1 = New ProgressForSwitchForm()


        ThreadT2 = New Threading.Thread(AddressOf ShowProgressForSwitchForm)
        ThreadT2.Start(ProgressForSwitchFormT1)
    End Sub

    Friend Delegate Sub EndProgressForSwitchFormDelegate(ByVal ProgressFormT1 As ProgressForSwitchForm)

    ' 結束進度條
    Public Sub EndProgressBar()
        Dim EndProgressForSwitchFormDelegateT1 As New EndProgressForSwitchFormDelegate(AddressOf EndProgressForm)
        ProgressForSwitchFormT1.Invoke(EndProgressForSwitchFormDelegateT1, ProgressForSwitchFormT1)
    End Sub
    '''==================進度條End========================================================================
#End Region
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章