Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

thread control?

Status
Not open for further replies.

enigma333

Programmer
Jul 3, 2001
42
CA
I'm and trying to create a program flow as follows

Connect
if failed wait 30secs
else Continue
Retry Connect

if connected then process

basically i need to call a function that will retry a number of times at a particular info and then when it is successful resume the program flow.

I know a thread would do this with sleep but how do i prevent the program from continuing before connection has been made?
 
This really isn't a .NET specific question, more of a logic question. But I'll answer it anyway.

You need to do something like this:
Code:
iTryCount = 0
While iTryCount < 3
   If Not Connect() Then
      Sleep(30000) '1000 milliseconds per second
   Else
      bConnected = True
      Exit While
   End If
   iTryCount = iTryCount + 1
Wend
If Not bConnected Then
   'Return failed condition to calling function
Else
   'Return success condition to calling function
Endif

Chip H.
 
Yes but I do not know how to do the sleep function other than thread.sleep .... so either I have to determine the main thread (not started by me) or use another method of sleep.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top