B
B.J. Raiford
I have a web site that shows the weather for a location and I have a list of
weather sites that I regularly used ordered by preference. I had to do this
because the location that the client likes most goes down all of the time
and I get crap for it not working correctly. So basically I want to try a
list of images and display the first one that appears, the code I have below
works be it is way to slow because it waits for a network timeout to occur
and a WebException to be thrown before moving to the next item. Does anyone
have another idea of how this might be accomplished?
Private Sub LoadWeatherData()
Dim WeatherLinkPre(2) As String
Dim zipCode As String
Dim i As Integer
WeatherLinkPre(0) =
"http://www.weatherroom.com/weather?forecast=hourly&hwvtc=FFFF40&hwvbg=3E6DF
2&config=png&alt=hwicc&pands="
WeatherLinkPre(1) =
"http://www.weatherusa.net/forecasts/?forecast=hourly&alt=hwicc&config=png&p
ands="
WeatherLinkPre(2) =
"http://wxport.accuweather.com/wxpost/graphic.aspx?type=31&partner=wwwlink&z
ipcode="
'zip code is gathered from the database in my app
zipCode = DbConn.GetZip()
Dim testWB As New System.Net.WebClient()
For i = 0 To WeatherLinkPre.Length - 1 Step 1
Try
testWB.DownloadData(WeatherLinkPre(i) & zipCode)
_weatherLink = WeatherLinkPre(i) & zipCode
Exit For
Catch e As System.Net.WebException
'ignore exception and move on to next option
End Try
Next
End Sub
weather sites that I regularly used ordered by preference. I had to do this
because the location that the client likes most goes down all of the time
and I get crap for it not working correctly. So basically I want to try a
list of images and display the first one that appears, the code I have below
works be it is way to slow because it waits for a network timeout to occur
and a WebException to be thrown before moving to the next item. Does anyone
have another idea of how this might be accomplished?
Private Sub LoadWeatherData()
Dim WeatherLinkPre(2) As String
Dim zipCode As String
Dim i As Integer
WeatherLinkPre(0) =
"http://www.weatherroom.com/weather?forecast=hourly&hwvtc=FFFF40&hwvbg=3E6DF
2&config=png&alt=hwicc&pands="
WeatherLinkPre(1) =
"http://www.weatherusa.net/forecasts/?forecast=hourly&alt=hwicc&config=png&p
ands="
WeatherLinkPre(2) =
"http://wxport.accuweather.com/wxpost/graphic.aspx?type=31&partner=wwwlink&z
ipcode="
'zip code is gathered from the database in my app
zipCode = DbConn.GetZip()
Dim testWB As New System.Net.WebClient()
For i = 0 To WeatherLinkPre.Length - 1 Step 1
Try
testWB.DownloadData(WeatherLinkPre(i) & zipCode)
_weatherLink = WeatherLinkPre(i) & zipCode
Exit For
Catch e As System.Net.WebException
'ignore exception and move on to next option
End Try
Next
End Sub