I've done what you suggest with WebRequest but it seems it's quite
a thread hog if it's called every second. Unless I put it in its own thread
the UI thread is visibly interupted.
Hmmm, maybe instead of pinging a website it pinged the NIC default IP
gateway on one's PC, this would give better performance?
Nice method though, quick and easy.
Adam
I'm not sure what you mean by "called every second". Here is a snip
of something I use. When the execution gets to this point, it's
either a valid response, or there was an exception. On a broadband
connection, here, from the time the URL is selected until the picture
is completely displayed is generally 2-3 seconds. Exceptions other
than timeout are virtually instaneous.
(Code is used in a BackgroundWorker component, DoWork event)
Try
Dim request As HttpWebRequest =
DirectCast(WebRequest.Create(PicLoc), HttpWebRequest)
request.Timeout = 10000
Dim response As HttpWebResponse =
DirectCast(request.GetResponse(), HttpWebResponse)
If response.StatusDescription = "OK" Then
RequestStatus = True
End If
response.Close()
Catch ex As WebException
Select Case ex.Status
Case WebExceptionStatus.ConnectFailure
Case WebExceptionStatus.Timeout
Case WebExceptionStatus.ProtocolError
Case Else
end select
End Try
Gene