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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:38:44+00:00 2026-05-26T03:38:44+00:00

I have a long running process called ImportProductInformation called by a consoleapp that I’m

  • 0

I have a long running process called ImportProductInformation called by a consoleapp that I’m trying to speed up, which appears to be an excellent candidate for thread-pooling, so I did a little searching and came across SmartThreadPool on CodeProject and am trying to implement it.

ImportProductInformation currently requires an “item”, which is just a single entity-framework row pulled from a list. SmartThreadPool uses a delegate called "WorkItemCallback", but if I build it like below it complains about “Method name expected” in the foreach loop on smartThreadPool.QueueWorkItem, as it appears I can’t pass my params to the delegated method. What am I missing here? I’m sure it’s something stupid…noob lacking experience with delegates…any help would be appreciated:

    public static void ImportProductInformation_Exec()
    {
        // List
        List<productinformation> _list = GetProductInformation();

        // Import
        if (_list != null)
        {
            SmartThreadPool smartThreadPool = new SmartThreadPool();

            foreach (var item in _list)
            {
                smartThreadPool.QueueWorkItem
                  (new WorkItemCallback
                    (ImportProductInformation(item)));
            }

            smartThreadPool.WaitForIdle();
            smartThreadPool.Shutdown();
        }
    }

    public void ImportProductInformation(productinformation item)
    {
        // Do work associated with "item" here
    }

If I change the loop to this I get “Method is used like a Type” in the build error:

            foreach (var item in _list)
            {
                ImportProductInformation ipi = 
                  new ImportProductInformation(item);

                smartThreadPool.QueueWorkItem(new WorkItemCallback(ipi));
            }

Ended up getting it to work with this:

public class ProductInformationTaskInfo
{
    public productinformation ProductInformation;

    public ProductInformationTaskInfo(productinformation pi)
    {
        ProductInformation = pi;
    }
}

public class PI
{
    foreach (var item in _list)
    {
        ProductInformationTaskInfo pi = 
          new ProductInformationTaskInfo(item);
        smartThreadPool.QueueWorkItem
          (new WorkItemCallback
            (ImportProductInformation), pi);
    }

    public static object ImportProductInformation(Object _pi)
    {
        ProductInformationTaskInfo pi = (ProductInformationTaskInfo)_pi;
        var item = pi.ProductInformation;

        // Do work here
    }
}
  • 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-26T03:38:45+00:00Added an answer on May 26, 2026 at 3:38 am

    I don’t know or have the SmartThreadPool, the following is approximate:

    foreach (var item in _list)
    {
       var itemCopy = item;
       smartThreadPool.QueueWorkItem
                  (dummy => ImportProductInformation(itemCopy));
    }
    

    You may have to do some fixing.
    This works because the lambda captures a variable from the containing method. And that’s why you need itemCopy.

    But note that the normal ThreadPool is not suited for longrunning tasks, the same may hold for the SmartThreadPool. It should also keep a limit on the number of threads, and when ImportProductInformation does mainly I/O threading might not help at all.

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

Sidebar

Related Questions

I have a long running process in VB6 that I want to finish before
I have a python web application that needs to launch a long running process.
I have a long running PHP process, that sometimes hangs in a loop. This
I have a long running process that needs to do a lot of queries
I have a client that starts a long running process on the server. At
I have a long running process that integrates over a collection of incoming Entities
I have a long running process (40+ min) that I am debugging. I don't
Greetings, In the application that I am working on, I have a long-running process
I have a long running background process that parses a few hundred thousand lines
We have a java application that's essentially a long running process. It's deployed on

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.