Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've been given a project that i'm about to start. Its basic function is to connect to 6 or 7 websites, fill out some form data and then scape some information from the results pages and display it to the user. Its for price comparison, similar to confused.com.

 

Each site it connects to takes about 30 seconds to get to the results, so I was hoping to connect them all concurrently on seperate threads.

 

There will be seven different functions which all return the same custom object. Can I call these functions on different threads? How would I go about it?

 

Thanks

  • Administrators
Posted

Depending on how you are communicating with the server(s) this might be easy enough to do. If you are using the HttpWebRequest class to communicate it offers a Begin / End GetResponse pair of methods that could be used.

 

If you give a bit more detail about how you are currently approaching the problem then we can offer a bit more specific advice.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi PD,

 

I'm manipulating the controls of each web page inside a web browser control.

 

Basic Example:

Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function

Private Function GetCurrentWebForm() As mshtml.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function

Private Sub SetTextareaText(ByVal Text As String)
DirectCast(GetCurrentWebForm.item("txtArea"), mshtml.HTMLTextAreaElement).value = Text
End Sub

Private Sub ClickNormalButton()
DirectCast(GetCurrentWebForm.item("cmdClickMe", 0), mshtml.HTMLButtonElement).click()
End Sub

 

I was thinking about having 7 web browser controls, all invisible which are manipulated on 7 threads with the results being returned as they complete to the UI thread.

 

Is this the correct approach do you think?

 

Thanks

  • Administrators
Posted

You might find it pretty nasty to work with multiple controls in that way from multiple threads - you shouldn't interact with the UI (or UI controls) from anything other than the main UI thread.

 

It might be better in the long run to see if it's possible to just post the correct values to the site and read the returned response directly.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...