المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : System Blocked using ThreadPool



C# Programming
09-16-2009, 07:42 AM
I'm working in an application wich works with more than 100 threads belonging to ThreadPool in a common job, so I create the WaitCallback object pointing to a method, next from the Main Thread with a For sentence I start creating Threads, and I see:

1) if all the execution procedure is self-contained in the method called with the WaitCallBack object, ever thread start working from it´s creation an everything works correctly.

2) but if for finish the job the pointed method needs to use any other method outside itself, now the Main Thread takes the complete execution time and no other Thread start working until the Main Thread finish creating all the Threads.

So I don`t know how to avoid using Class or methods externals to the method pointed by the WaitCallback object. And the big quantity of created Threads, without discarging one until the end of creation process in the Main Thread, makes the system blocked before finishing.