I've wrote that code as a small example of how I am using it. I am using it in WebSocket class and I am assigning private variable instead of True.
Private FirstActionEnabled as Boolean
Sub RunFirstAction()
FirstActionEnabled = True
Do While FirstActionEnabled
' get some data from websocket
' post some data to another external server
Sleep(5000)
' get some data from the external server
End While
End Sub
Sub StopFirstAction()
FirstActionEnabled = False
End Sub
I have about 9 of this 'action' subs for each websocket. 4 of them I start right after WebSocket_Connected and run for as long as the WebSocket is Open and 5 of them I start and stop if some code condition is met when I get data from client (browser) via websocket.
My project isn't finished yet. I am collecting data from other applications(point of sale applications), analizing it and update the db of my project and the client(browser) view. Basically all the external servers are local vb6 applications that produce some logs now and then and I am centralizing that data so I and the users using those applications can see their data in a modern way (i am using abmaterial for the gui of my project).
From my point of view is simple to use the Sleep method and the code is more 'clean' instead of Timers but what I really don't get is what happens to the loop when Sleep is called
is it left hanging ? It exits the loop and after sleep is finished it recreates the loop?