Hi

I am using VB.Net 2002. I have the following code that works but takes too much time to execute. Any another way (that works ).

VB Code:
  1. Public Function IsConnectionAvailable() As Boolean
  2.     ' Returns True if connection is available
  3.     ' Replace [url]www.yoursite.com[/url] with a site that
  4.     ' is guaranteed to be online - perhaps your
  5.     ' corporate site, or microsoft.com
  6.     Dim objUrl As New System.Uri("http://www.yoursite.com/")
  7.     ' Setup WebRequest
  8.     Dim objWebReq As System.Net.WebRequest
  9.     objWebReq = System.Net.WebRequest.Create(objUrl)
  10.     Dim objResp As System.Net.WebResponse
  11.     Try
  12.         ' Attempt to get response and return True
  13.         objResp = objWebReq.GetResponse
  14.         objResp.Close()
  15.         objWebReq = Nothing
  16.         Return True
  17.     Catch ex As Exception
  18.         ' Error, exit and return False
  19.         objResp.Close()
  20.         objWebReq = Nothing
  21.         Return False
  22.     End Try
  23. End Function
'Here’s how you might use this function in your application:
VB Code:
  1. If IsConnectionAvailable() = True Then
  2.     MessageBox.Show("You are online!")
  3. End If