will help you It's 100% possible to use COM objects with the TPL. While it's true that, by default, the TPL will use the standard .NET ThreadPool, the TPL has an extension point via the TaskScheduler class which enables you to provide your own scheduler which can dispatch work to threads which you've created. In the case of of using COM objects you first need to know if the COM class requires STA threading or MTA threading. If MTA threading, then there's nothing special that needs to be done because the COM class can already be used from any random thread. Unfortunately most classic COM objects tend to rely on STA threading and that's when you'd need to employ a custom TaskScheduler so that whatever .NET thread you're using them from has been initialized as an STA compatible thread.
// Create a static instance of the scheduler specifying some max number of threads
private static readonly StaTaskScheduler MyStaTaskScheduler = new StaTaskScheduler(4);
// Then specify the scheduler when starting tasks that need STA threading
MyComObject myComObject = new MyComObject();
// ... etc ...
Why does the Task Parallel Library have a 'hidden' 1 second timeout for scheduling tasks under certain conditions?
should help you out The behavior that you are seeing is not specific to the TPL, it's specific to the TPL's default scheduler. The scheduler is attempting to increase the number of threads so that those two that are running don't "hog" the CPU and choke out the others. It's also helpful in avoiding deadlock situations if the two that are running start and wait on Tasks themselves. If you want to change the scheduling behavior, you might want to look into implementing your own TaskScheduler.
Parallel Processing with Starting New Task - front end screen timeout
will be helpful for those in need I think, best way for parallel processing in SAP is Bank Parallel Processing framework as Jagger mentioned. Unfortunently its rarerly mentioned in any resource and its not documented well. Actually, best documentation I found was in this book https://www.sap-press.com/abap-performance-tuning_2092/
HttpClient Parallel Requests Timeout using Task.WhenAll when one request times out
will be helpful for those in need If any of the supplied tasks completes in a faulted state, the returned task will also complete in a Faulted state, where its exceptions will contain the aggregation of the set of unwrapped exceptions from each of the supplied tasks.
Distributed Julia: parallel map (pmap) with a timeout / time limit for each map task to complete