Bill Nguyen wrote:
Tom;
That seemed to solve my problem. I assinged 1000 miliseconds and CPU time
went down significantly. memory used still about the same, but that I can
afford!
Another question, please:
I need to interrupt the loop when user presses the STOP button. The problem
that btnStop(on the same form) is not accessible during the loop.
Is there a way to check if the button was pressed during the do loop
routine?
Hello Bill,
I'd consider changing you code as follows (Watch for line-wrapping) -
Dim blExitLoop as Boolean = False 'Place this in General Declarations
Section
Dim t As Integer = 0
Dim Start, Finish, TotalTime As Double
'Start = Microsoft.VisualBasic.DateAndTime.Timer
Finish = Start + mSeconds ' Set end time for mseconds duration.
Do While Microsoft.VisualBasic.DateAndTime.Timer < Finish And blExitLoop
= False
t += 1
lblInfo.Text = "test timer -> " & t
'lblInfo.Refresh() 'You can REMOVE this now!
System.Threading.Thread.Sleep(100)
System.Windows.Forms.Application.DoEvents()
' Do other processing while waiting for 5mseconds to elapse.
Loop
(Note the change to your "Do While... Loop above!)
I'd then put the following in your "Stop" Button Click Event -
blExitLoop = True
I hope this helps.
ShaneO
There are 10 kinds of people - Those who understand Binary and those who
don't.