Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:10:18+00:00 2026-06-10T05:10:18+00:00

I am trying to understand the best method to speed up a little program

  • 0

I am trying to understand the best method to speed up a little program that searches for strings in the source of multiple websites. The program as it stands is as follows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim urls() As String = TextBox1.Lines()
Dim stringstofind() As String = TextBox2.Lines()
For Each url As String In urls
    CheckForStrings(url, stringstofind)
Next

End Sub
Private Sub CheckForStrings(ByVal url As String, ByVal stringstofind() As String)
Dim wc As New WebClient()
Dim source As String = wc.DownloadString(url)
'MessageBox.Show(source)
For Each stringtofind As String In stringstofind
    If (source.IndexOf(stringtofind) <> -1) Then
        TextBox3.AppendText("url: " + url + " string: " + stringtofind + vbCrLf)
        Exit For
    Else
        TextBox3.AppendText("url: " + url + " string: " + "NOT FOUND" + vbCrLf)
    End If
Next

End Sub

The options that seem available are:
Thread the initial for each loop using a parallel.for each. Apart from a few edits to avoid cross threading issues and blocking the GUI, it seems pretty simple to do, but doesnt seem like the best way to do it.

Use the webclient.DownloadStringAsync method.
This is the 1st thing i looked at, but i cant work out how to pass back the resulting string from the DownloadStringCompleted event.
Also, if i can work this out, how do you limit how many simultainious requests are made, to avoid overloading the network connection?

I also looked at some c# examples using .net4.5 that look great, but the program would need to run on server2003 so i guess thats out of the question

Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:10:19+00:00Added an answer on June 10, 2026 at 5:10 am

    I will post the comment as an answer as this is not getting much traffic.

    TPL allocates threads based on CPU it is not going to deal with slow connections that don’t put a load on CPU well.

    An easy start is WithDegreeOfParallelism to throttle. enter link description here

    You may find 100 is a good WithDegreeOfParallelism.

    The next level of optimization gets a lot more complex. If it is async, thread pool, or combination. It is going to depend so much on the latency of the websites. And I am not sure you would buy a lot with async as an idle thread is not that much overhead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a little problem to understand where should I add an method that
I'm trying to understand the best options for pulling off a wizard form in
Been trying my best to understand this correctly. What is the difference between an
I'm fairly new to C programming but trying my best to understand it. I
My question is a bit tricky, I am trying best to make you understand
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
I'm trying to understand some fundamental best practices using Entity Framework. My EDM design
I'm trying to understand the best way to map the fields in an Edit
I am trying to understand what is the best way to construct a query
I have a client/server question that i am trying to figure out the best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.