Задайте вопросЗадайте вопрос
 

ОтвеченоCode Required

Ответы

  • 22 июня 2009 г. 11:05Rong-Chun ZhangMSFT, МодераторМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено

    Hello ,

    You need to call Thread.Sleep method to force the current thread to block for one second. If you working with Windows Form Application, please try something like the following

        Delegate Sub SetText(ByVal txt As String)


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim t As New Thread(New ThreadStart(AddressOf InvokeMethod))
            t.Start()
        End Sub

        Private Sub IncrementalText(ByVal txt As String)
            If Me.Label1.InvokeRequired Then
                Dim pro As New SetText(AddressOf IncrementalText)
                Me.Invoke(pro, New Object() {txt})
            Else
                Me.Label1.Text = txt
            End If
        End Sub

        Private Sub InvokeMethod()
            For i As Integer = 1 To 100
                Thread.Sleep(1000)
                IncrementalText(i.ToString())
            Next
        End Sub

    More information,
    http://msdn.microsoft.com/en-us/library/ms171728.aspx

    Since this forum is for Visual SourceSafe, questions about VB.NET, please ask on VB.NET forum.
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads

    Thanks,
    Rong-Chun Zhang


    Please mark the replies as answers if they help and unmark if they don't.
    Welcome to the All-In-One Code Framework, a sample code project owned by the MSDN Forum Support team!

Все ответы