"The request was aborted" exception in long process

Hi,

I’m having a problem calling long process with a BackgroundWorker after a while I get this error message "The request was aborted: The request was canceled"

What I’m doing is login a site go to a submit page form and submit data, the tool submit articles to differents article directories, after more and less 100 articles I get the "The request was aborted: The request was canceled" message, if I run again the app I get the error message in the number 1 item like if the connection is still alive and I need to reboot my pc.

So, the loop method is here:

visual basic code:--
Function SubmitAll(ByVal bw As BackgroundWorker) As Integer
Dim oSubmitRobot As New clsSubmitRobot
Try
For Each oItem As Object In oSubmitList
If bw.CancellationPending = True Then
Exit Function
End If
With oSubmitRobot
.LoadValues(CInt(oItem))
.Submit()
MyWorkerRobot.ReportProgress(intProgress)
intProgress = intProgress + 1
End With

Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try

End Function
--
I think is something with the webReq.Timeout = 999999999 because in my first test I setup the timeout to 50000 and the submission was like only 40 articles or maybe I need to call the garbage collector to remove everthing from the memory
And here it is the code inside the Submit() method in the clsSubmitRobot object:

visual basic code:--
Try

Dim cookieJar As CookieContainer = New CookieContainer
Dim webReq As HttpWebRequest
Dim webResp As HttpWebResponse
Dim sr As StreamReader
Dim sw As StreamWriter
Dim urlString As String = "http://www.articleDomain.com/Login.php"
'I get the login page
webReq = CType(WebRequest.Create(New Uri(urlString)), HttpWebRequest)
webReq.CookieContainer = cookieJar
webReq.Credentials = CredentialCache.DefaultCredentials
webReq.KeepAlive = True
webReq.Timeout = 999999999
webReq.Method = "GET"
webResp = webReq.GetResponse
sr = New StreamReader(webResp.GetResponseStream)
txt = sr.ReadToEnd.Trim
sr.Close()
webResp.Close()

'Now I post the login details

webReq = CType(WebRequest.Create(New Uri(urlString)), HttpWebRequest)
webReq.CookieContainer = cookieJar
webReq.Credentials = CredentialCache.DefaultCredentials
webReq.KeepAlive = True
webReq.Timeout = 999999999
webReq.Method = "POST"
webReq.ContentType = "application/x-www-form-urlencoded"
strParameters = "username=" & FUserName & "&password=" & FPassword
webReq.ContentLength = strParameters.Length
sw = New StreamWriter(webReq.GetRequestStream)
sw.Write(strParameters)
sw.Close()
webResp = webReq.GetResponse
sr = New StreamReader(webResp.GetResponseStream)
txt = sr.ReadToEnd.Trim
sr.Close()
webResp.Close()

'Finnally I post the data in another page inside the site

webReq = CType(WebRequest.Create(New Uri("http://www.articleDomain.com/Submit.php")), HttpWebRequest)
webReq.CookieContainer = cookieJar
webReq.Credentials = CredentialCache.DefaultCredentials
webReq.KeepAlive = True
webReq.Timeout = 999999999

webReq.Method = "POST"
webReq.ContentType = "application/x-www-form-urlencoded"
strParameters = "title=" & Title & "&url=" & Body
webReq.ContentLength = strParameters.Length
sw = New StreamWriter(webReq.GetRequestStream)
sw.Write(strParameters)
sw.Close()

webResp = webReq.GetResponse

sr = New StreamReader(webResp.GetResponseStream)
txt = sr.ReadToEnd.Trim

sr.Close()
webResp.Close()


Catch ex As Exception
Throw ex
End Try
--
Any help is going to be more than appreciate
[4222 byte] By [Diego_VB] at [2007-12-23]