all groups > dotnet distributed apps > october 2003 >
You're in the

dotnet distributed apps

group:

How to stop while loop


How to stop while loop Prasad
10/31/2003 9:02:02 PM
dotnet distributed apps:
Hi:

See this code :
While iCommand.Connection.State = ConnectionState.Closed

Try

iCommand.Connection.Open()

Exit While

Catch ex As Exception

Console.Write(ex.ToString())

End Try



End While

In the above code, checking connection state if closed database connection
will be established. If any exception occurs while connecting, printing to
console and again try to connect to database. Here, in catch block, i want
to stop for 10 or 20 seconds while attempting to connect again (stop while
loop for some time). How can make it. Don't say use empty for loop in
catch block, after for completes, while loop will be continued. This is a
windows service and memeory usage is a big issue.



Thanks in advance.

-Prasad.





Re: How to stop while loop Laurie Paulin
11/3/2003 1:17:35 PM
System.Threading.Thread.Sleep(10000)

[quoted text, click to view]

How to stop while loop anonymous NO[at]SPAM discussions.microsoft.com
12/30/2003 12:38:05 PM

Thread.Sleep(2000)


[quoted text, click to view]
AddThis Social Bookmark Button