|
-
Aug 24th, 2001, 09:20 AM
#1
Thread Starter
New Member
Continuous Operation
I've got a program I'm creating that polls industrial units through the serial port. These units must be polled continuously at the quickest rate possible, and must run endlessly. So I have two questions:
1. How can I create a really small, small delay (about 10 ms)? The VB timer only allows me to have delays accurate to approx 70 ms.
2. How can I have my program run continuously without running out of stack memory. The way it is now, once started, it calls a sub which calls another sub which calls the first sub again. I don't know how else to make it run endlessly, but the stack fills up so quickly!
Any ideas? Any help would be appreciated.
-
Aug 24th, 2001, 09:30 AM
#2
You can use the Sleep API to pause and put your code in a loop.
VB Code:
Private Declare Sub Sleep _
Lib "kernel32" ( _
ByVal dwMilliseconds As Long)
Private blnStop As Boolean
Private Sub doTheWork()
Do While True 'an never ending loop
'do the work
Sleep 10
DoEvents
If blnStop Then
Exit Sub
End If
Loop
End Sub
Private Sub Form_Unload()
blnStop = True
End Sub
Best regards
-
Aug 24th, 2001, 09:41 AM
#3
Thread Starter
New Member
Works
Thanks.
It seems to be working now. I feel kinda silly because it was so simple!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|