stop after a certain period

leontager

Well-known member
Joined
Jun 17, 2003
Messages
89
Hi, I have a sub called reconnect. How can I make my program run the sub and if after 20 seconds it wasnt finished close it?
 
Originally posted by leontager
Hi, I have a sub called reconnect. How can I make my program run the sub and if after 20 seconds it wasnt finished close it?

You could run it in another thread. Then using a timer check to see if the thread is still running, and if it is terminate it and display a error message about not being able to reconnect.

Something like this:

Code:
Declare the thread
Dim objThread as System.Threading.Thread

Instantiate the thread with the starting function
objThread = New System.Threading.Thread(AddressOf Reconnect)

Start the thread
objThread.Start()

Then you can use the timer to check the status of the objThread object.
 
Back
Top