AboutSyed Rizwan Muhammad Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.
Experience Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.
Expert: Syed Rizwan Muhammad Rizvi Date: 5/15/2006 Subject: My.Computer.Network.DownloadFile hangs a long time
Question I have the following code in VB.NET:
Dim t As DateTime
t = Now
My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google1.html"), "", "", False, 100 * 1000, True)
Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")
t = Now
My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google2.html"), "", "", False, 100 * 1000, True)
Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")
t = Now
My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google3.html"), "", "", False, 100 * 1000, True)
Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")
Debug.WriteLine("")
I executed this code three times in a row and got this this debug-output:
'12,6829146 sec.
'0,100181 sec.
'0,0500905 sec.
'0,0801448 sec.
'0,0500905 sec.
'0,0601086 sec.
'0,0601086 sec.
'0,0500905 sec.
'0,0601086 sec.
As you can see, the first download has a huge delay. After that, it goes smooth. If I repeat this like 5 minutes later, the first request is delayed again, but all requests after that are allways fast.
Why is this?
Answer I hope you are not on Wireless LAN, seems more like a network problem to me than coding problem, it appears that the proxy caches the file after first download so your later downloads are faster, also the API's normally use IE's settings to connect to internet check to see if IE is set to discover proxy automatically, that can also be a cause of delay. really can only analyze the problem on your machine rather than anywhere else.