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

  • Home
  • SEARCH
  • 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 6976461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:29:59+00:00 2026-05-27T17:29:59+00:00

I have two questions: Is there a way to insert a ThreadPool functoin that

  • 0

I have two questions:

  1. Is there a way to insert a ThreadPool functoin that dosen’t gets
    object as parameter(to insert a function to threadPool it need to be function that return void and ged one parameter -object) e.g i want to insert this function: double foo(int a,double b,string c)?
  2. Is there a way to wait to thread in the pool (like join)?
  • 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-27T17:30:00+00:00Added an answer on May 27, 2026 at 5:30 pm

    For the first part, the easiest approach is probably:

    Assuming a method per your description:

    public double foo(int a, double b, string c)
    {
        ...
    }
    

    You can queue this on the thread pool with:

    ThreadPool.QueueUserWorkItem(o => foo(a, b, c));
    

    For the second part, while you can’t wait on a ThreadPool thread, you can call methods asynchronously on the thread pool, and wait on their completion (which seems to be what you’re looking for).

    Again, assuming the Foo method is defined as above.

    Define a Delegate for Foo:

    private delegate double FooDelegate(int a, double b, string c);
    

    Then to call Foo asynchronously using the BeginInvoke/EndInvoke methods of the FooDelegate:

    // Create a delegate to Foo
    FooDelegate fooDelegate = Foo;
    
    // Start executing Foo asynchronously with arguments a, b and c.
    var asyncResult = fooDelegate.BeginInvoke(a, b, c, null, null);
    
    // You can then wait on the completion of Foo using the AsyncWaitHandle property of asyncResult
    if (!asyncResult.CompletedSynchronously)
    {
        // Wait until Foo completes
        asyncResult.AsyncWaitHandle.WaitOne();
    }
    
    // Finally, the return value can be retrieved using:
    var result = fooDelegate.EndInvoke(asyncResult);
    

    To address the question raised in the comments. If you want to execute multiple function calls in parallel and wait for them all to return before continuing, you could use:

    // Create a delegate to Foo
    FooDelegate fooDelegate = Foo;
    
    var asyncResults = new List<IAsyncResult>();
    
    // Start multiple calls to Foo() in parallel. The loop can be adjusted as required (while, for, foreach).
    while (...)
    {
        // Start executing Foo asynchronously with arguments a, b and c.
        // Collect the async results in a list for later
        asyncResults.Add(fooDelegate.BeginInvoke(a, b, c, null, null));
    }
    
    // List to collect the result of each invocation
    var results = new List<double>();
    
    // Wait for completion of all of the asynchronous invocations
    foreach (var asyncResult in asyncResults)
    {
        if (!asyncResult.CompletedSynchronously)
        {
            asyncResult.AsyncWaitHandle.WaitOne();
        }
    
        // Collect the result of the invocation (results will appear in the list in the same order that the invocation was begun above.
        results.Add(fooDelegate.EndInvoke(asyncResult));
    }
    
    // At this point, all of the asynchronous invocations have returned, and the result of each invocation is stored in the results list.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I have two questions. (1) Is there any reduction in processing power or
I have two questions: (1) I learned somewhere that -O3 is not recommended with
Two questions: 1) There are several tables that are used as an archive for
I have two noobish questions about Flash, Actionscript, Flex etc. 1) With these technologies
I have two questions: 1) How can I make an array which points to
I have two questions. Do realloc() and memcpy() copy the entries in an array
I have two questions: 1) I have a few global variables for my website
I have two questions: From personal experience, what free blog engine is the best
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
I have two questions 1) my interface i have interface called IRegister and within

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.