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.