Timer and webrequest notsupportedexception

G

Guest

Hi,

Hi i have a non visual application using a system timer
which calls a class to load data from xml urls
In my processData code i am doing a webrequest repeatedly
to get data from different url pages

objRequest = System.Net.WebRequest.Create(p_cUrl)
which works fine until you call it in the timer and then it says
NOTSUPPORTEDEXCEPTION

Any Ideas please
TIA - code below

Stu

Dim objSettings As New clsSettings
Dim arDataUrls() As String
Dim objTimerState As Object
Dim objProcess As New clsProcess

Dim autoEvent As New AutoResetEvent(True)
Dim delayTime As New TimeSpan(0, 0, 0)
Dim intervalTime As New TimeSpan(0, 0, 0, _gnPollInterval)
Dim objTimer As Timer

Dim timerDelegate As TimerCallback = _
AddressOf objProcess.processData

Try

arDataUrls = objSettings.loadSettings()

If IsNothing(arDataUrls) Then
Throw New Exception("Unable to load setting information")
Else
With objProcess
.urlDataArray = arDataUrls
.overLayFileName = _gcOverlayFile
End With

objTimer = New Timer(timerDelegate, autoEvent, delayTime,
intervalTime)
'objProcess.processData(objTimerState)
End If
Catch ex As Exception

End Try
 
S

Sergey Bogdanov

I was trying to reproduce this issue [1] but without luck. Can you run
it with your code?

Also what value had p_cUrl? The WebRequest.Create factory method could
throw NotSupportedException when the request scheme specified in the
requestUriString parameter has not been registered.

Meanwhile I suppose that that the problem were somewhere else in your
code, try to run in Debug mode and see where the exception was thrown.

[1] http://www.sergeybogdanov.com/Test/TimerAndRequest.zip
 
Top