Alisson Suart 0 Posted Thursday at 11:47 AM Hello everybody, I have a process using a "cloning" of idThreadsComponents in my form. This cloning is based on the number of companies that I need to execute the process that I have. I can have 1 thread or more than 20 idThreads. I would like to understand if, if I add the idSchedulerOfThreadPool, and put a Pool Size = 5, if it will execute a queue of these 20 threads, that is, executing 5 threads at a time. In my process I just do a Start to start and when the whole process ends, I do a Stop. Then I wait with a Timer until the set time is reached to repeat the process. Would it be correct to use it this way? I have doubts about these Scheduler components and how to use them. If you can help me. I thank. Share this post Link to post
Remy Lebeau 1390 Posted Thursday at 02:35 PM I don't really understand what you're trying to do. But the Scheduler components are not intended to be used standalone, they are meant to be used with TIdTCPServer and derived components. That being said, the pool size only effects the number of threads that are sitting idle in the pool. Not the number of threads that are actively running. Share this post Link to post
Alisson Suart 0 Posted Thursday at 05:36 PM I'll try to explain it another way. I have a form that contains 10 idThreadsComponent components ( TidThreadComponents). I want each of them to run separately, but in a time interval. It turns out that I have had cases where Windows gave an error that there were no more resources available to allocate these threads in memory, and this caused the failure. I was thinking that, if I add any of the Scheduler components, this execution management would be done by the component, so that there is no overhead of threads running in Windows, and it no longer causes the unavailable resource error. (Sorry, I'm translating the message). Vou tentar explicar de outra forma. Eu tenho um form que contém 10 componentes idThreadsComponent. Cada um deles eu quero que execute separadamente, porém em um intervalo de tempo. Acontece que eu tive casos que o windows deu um erro que não havia mais recursos disponíveis para alocar essas threads em memoria, e com isso causa a falha. Eu estava pensando que, se adicionar algum dos componentes Scheduler, se esse gerenciamento de execução seria feito pelo componente, para que não haja sobrecarga de threads em execução no windows, e com isso não de mais o erro de recurso indisponível. Share this post Link to post
Remy Lebeau 1390 Posted Thursday at 11:06 PM 5 hours ago, Alisson Suart said: It turns out that I have had cases where Windows gave an error that there were no more resources available to allocate these threads in memory, and this caused the failure. Windows has enough resources to run thousands of threads in parallel. 10 is nothing. So something else is likely causing the error. 5 hours ago, Alisson Suart said: I was thinking that, if I add any of the Scheduler components, this execution management would be done by the component, so that there is no overhead of threads running in Windows, and it no longer causes the unavailable resource error. The Scheduler manages only threads that it creates. It can't manage threads created by TIdThreadComponent. But again, the Scheduler doesn't limit threads that are running, only threads that are idle. When the Scheduler needs a thread, it pulls one from the pool if available, otherwise it creates a new one. When a thread is finished, it is put in the pool if there is room for it, otherwise it is terminated. 1 Share this post Link to post