Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I want to download a string from a page in my site, so I use this and it works:

NewString = WebClient.DownloadString("http://www.domain.com/setup.txt")

Just 1 problem that if there is a connection timeout, my application hangs out.

So should I use WebClient.DownloadStringAsync?

If so how?

I wrote this code but it doesn't work:

               Dim SiteURI As New Uri("http://www.domain.com/setup.txt")
               NewString = WebClient.DownloadStringAsync(SiteURI)

Please help me :(

  • Administrators
Posted

Chuck this into a blank form and you should get the general idea

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim SiteURI As New Uri("http://www.xtremedotnettalk.com/showthread.php?p=465032#post465032")
   Dim wc As New WebClient
   wc.DownloadStringAsync(SiteURI)
   AddHandler wc.DownloadStringCompleted, AddressOf Test

End Sub

Private Sub Test(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
   Dim newstring As String = e.Result
End Sub

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...