Asynchronous HTTP Download

  • Thread starter Thread starter VBTricks.de.vu Webmaster
  • Start date Start date
V

VBTricks.de.vu Webmaster

Hello everybody,

I need to write a HTTP client capable of downloading files using the
HTTP protocoll. But downloading is one of my problems. I'm new to VB.net
and I know there's a framework offering a solution for almost every
problem. But for me it's a bit complex.

So what I need:
I need a way to download files asynchronously. In VB6 I solved this
problem with a self-written component using sockets. As of the large
amount of classes in the net-framework I was first looking for a
built-in solution offering me the same functionality. I found various
samples working with HttpWebRequest and a StreamReader. But makeing this
asynchronous using a timer calling the Read method of the StreamReader
does not really make sense.

So is there a way to implement it that way that there occurs an event
when new data has been read from the server or do I have to implement it
using Sockets?


Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_____________________________________________________
 
I just wrote one for a client using the HttpWebRequest class.

I created a download worker thread that requested a chunk of data from the
read stream. It tends to read smaller chunks than desired on my system but
careful byte count management seems to work.

The events were provided in the form of a couple of delegates that passed a
custom event argument back containing filesize and percentage done, time
remaining and so-on.

I'd post the code but it's not mine.

HttpWebRequest is definitely the way to go.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
But when implementing it using a timer, it freezes the applikation (when
timer interval is set too small). Otherwise, it will not use the full
speed of the connection (when timer interval is set to high).

Is there no way to be informed by HTTPWebRequest when new data has arrived?


Stefan


--
___________________________________www.VBTricks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_____________________________________________________
 
Back
Top