I have two questions:
- Is there a way to insert a
ThreadPoolfunctoin 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)? - Is there a way to
waitto thread in the pool (like join)?
For the first part, the easiest approach is probably:
Assuming a method per your description:
You can queue this on the thread pool with:
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
Foomethod is defined as above.Define a Delegate for Foo:
Then to call Foo asynchronously using the BeginInvoke/EndInvoke methods of the FooDelegate:
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: