Q: how to set a break

hi,

when you have a great amount of regular processes its some how freez your project and doesn't show the reslt untill it all done for example

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

For i As Integer = 1 To 1000

For S As Integer = 1 To 1000

Label1.Text &= (i + S).ToString & vbNewLine

Next

Next

End Sub

so how can i set a restrect for this process not to continue unless the label show the result , or to wait 1 second between one proccess and another

is there any idea

thx




Answer this question

Q: how to set a break

  • Jason22

    hi,

    many thx Michiel, it worked very great



  • Mohamed Raafat

    Hi,

    To get the proccess to wait one second, you can do the following:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim dDate1, dDate2 As DateTime

    For i As Integer = 1 To 1000

    For S As Integer = 1 To 1000

    dDate1 = Now

    dDate2 = dDate1

    Label1.Text &= (i + S).ToString & vbNewLine

    While DatePart(DateInterval.Second, dDate1) + 1 > DatePart(DateInterval.Second, dDate2)

    dDate2 = Now

    End While

    Next

    Next

    End Sub

    Regards,

    Jeroen Boiten



  • f-l-i-p

    If it's a Windows Forms application, you can make it more responsive by including the following statement in any tight loops:

    Application.DoEvents()

    This will give your application the chance to handle other events, such as pending repaints.

    To make your application go to sleep for longer periods, use System.Threading.Thread.Sleep: your application will do nothing (including screen redraws and such) for the specified millisecond interval. Going to sleep for small periods of time (say, 50 ms) in certain processing loops can keep your app from spiking the CPU at 100% (of course, total runtime will be longer, but the end-user experience will be a lot nicer).

    '//mdb


  • Q: how to set a break