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

The Archive Base Latest Questions

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

i have 20,000 items in a queue, and i want to process them using

  • 0

i have 20,000 items in a queue, and i want to process them using the threadpool.
will this be the best way to do it?

for i as integer = 0 to 19999
ThreadPool.QueueUserWorkItem (PerformTask, ListTask(i))
next

Sub PerformTask(i as string)
' do the work here
end sub

How can i return or set ui control from the PerformTask sub?

  • 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-23T09:44:43+00:00Added an answer on May 23, 2026 at 9:44 am

    You cannot.

    However, you can allocate a container (array, list) with a different slot for each result, and write into it. Alternatively, you could pass an object into the worker method that holds both the input and the result. I’d use this method:

    Class TaskObject
        Dim Input As String
        Dim Result As Whatever
    End Class
    
    Dim tasks As TaskObject() = New TaskObject(20000) { }
    
    For i as Integer = 0 to tasks.Length - 1
        ThreadPool.QueueUserWorkItem(PerformTask, tasks(i))
    next
    
    Sub PerformTask(arg As Object)
        Dim task As TaskObject = DirectCast(arg, TaskObject)
        ' do the work here
    end sub
    

    Unrelated: you should always enable Option Strict in your projects. No exception. Your code has type errors that the compiler should detect.

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

Sidebar

Related Questions

I have lists of about 20,000 items that I want to insert into a
I currently have about 650,000 items in memcached (430MB memory used) and the number
I have a dictionary of 200,000 items (the keys are strings and the values
Lets say I have around 1,000,000 users. I want to find out what position
I Have A ListBox With 10,000 Items And Many Many Duplicate Items! I Wonna
I have code that is adding ~100,000 items to a List. If I add
In some library code, I have a List that can contain 50,000 items or
I'm working with a CSV file in python, which will have ~100,000 rows when
What is the best way to show friends' posts? Each user can have maximum
I have a big List that may have some 50,000 or more items and

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.