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 6086113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:42:55+00:00 2026-05-23T11:42:55+00:00

i have this code which i run with queued 10,000, even when a max

  • 0

i have this code which i run with queued 10,000, even when a max of 50 is set but the threadpool counts goes to high.

can anyone help me fish out the fault

Public Sub DoWork(ByVal objItem As Object)
        Dim objUrl as String = DirectCast(objItem, string)
        Try
            If objUrl Is Nothing Then
                exit sub
            End If

            Dim URL as New Uri(objUrl)

            AddItem(URL.AbsoluteUri,gethtml(URL))

        Catch ex As Exception
            debug.Print("Error " & ex.StackTrace )
        End Try

    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnStart.Click
        btnStart.Enabled =False
        ThreadPool.SetMaxThreads(50, 50)
        System.Threading.Thread.Sleep(1000)
        listView1.Items.Clear

        For Each sItem As String In txturls.Lines
            if sItem.Trim <>string.empty

                If sItem.Contains("http://")=False Then
                    sItem="http://" & sItem
                End If

                ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf DoWork), sItem)
                TotalItems+=1
                tsslTotal.Text =String.Format ("Total Tasks: {0}",TotalItems)

            end if
        Next

    End Sub

thanks

EDIT

for those who asked,

GetHtml gets the web page source from the Internet

AddItem adds the result if the GetHtml to Listview

thanks again for looking

EDIT

i use a this code to check the number of runing threads each second

Sub Timer1Tick(sender As Object, e As EventArgs)
        tsslthreads.Text=string.Format ("Threads: {0}", Process.GetCurrentProcess().Threads.Count)
    End Sub

thanks

  • 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-05-23T11:42:56+00:00Added an answer on May 23, 2026 at 11:42 am

    Just wrote a small demo project. Try this code to check for available Threads and you will see, that there are only 50 threads RUNNING. compare: Your code will queue 10000 threads

    private void timer1_Tick(object sender, EventArgs e)
        {
            int workerThreads = 0;
            int completionPortThreads = 0;
            ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
    
            lblTotal.Text = string.Format("Worker {0}/Completion {1}", workerThreads, completionPortThreads);
        }
    

    My code is in c# and I had a timer added for showing the number of threads ..

    hth

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

Sidebar

Related Questions

I have a question concerning this code which I want to run on QNX:
I have this code which gets WP posts, but it gets all the posts
I have this code which is called at an onChange event of an function
I have this code (which is way simplified from the real code): public interface
I have this code which compiles and works as expected: class Right {}; class
I have this code which will include template.php file from inside each of these
I have this code which should create a splash image with either no animation
Problem Hello all! I have this code which takes my jpg image loops through
I am trying to compare two dates. I have this code which I thought
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);

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.