C
Cor Ligthert
Hi Hefried,
Show me where this will help, I changed the code to make it testable, this
works very good.
However when I bring the loop down to 10000 it is almost impossible to reach
the cancel button.
So show me what the multithread can do to help this with a loop of 2000
records in the dataset, without slowing the loop down.(The recordset loop
needs probably much less time, because there is no screen painting)
I spent some time on it, so I expect an answer.
Cor
\\\
Private CancelPrint As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Start"
Me.ProgressBar1.Maximum = 1000000
Me.ProgressBar1.Value = 1
End Sub
Private Sub CmdCancel_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
CancelPrint = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
CancelPrint = False
Button2.Focus()
Do While ProgressBar1.Value < ProgressBar1.Maximum _
And CancelPrint = False
Application.DoEvents()
ProgressBar1.Value += 1
Loop
If CancelPrint Then
MsgBox("Printing Canceled By User", MsgBoxStyle.Exclamation)
End If
End Sub
///
Be sure that I read the thread. The problem will go away when using
multithreading.
Show me where this will help, I changed the code to make it testable, this
works very good.
However when I bring the loop down to 10000 it is almost impossible to reach
the cancel button.
So show me what the multithread can do to help this with a loop of 2000
records in the dataset, without slowing the loop down.(The recordset loop
needs probably much less time, because there is no screen painting)
I spent some time on it, so I expect an answer.
Cor
\\\
Private CancelPrint As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Start"
Me.ProgressBar1.Maximum = 1000000
Me.ProgressBar1.Value = 1
End Sub
Private Sub CmdCancel_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
CancelPrint = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
CancelPrint = False
Button2.Focus()
Do While ProgressBar1.Value < ProgressBar1.Maximum _
And CancelPrint = False
Application.DoEvents()
ProgressBar1.Value += 1
Loop
If CancelPrint Then
MsgBox("Printing Canceled By User", MsgBoxStyle.Exclamation)
End If
End Sub
///