Catalog · How the catalog works
OtsThreadPool
OtsThreadPool :: Execução de tarefas em multi-threads - Delphi
- ★ 5 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
OtsThreadPool
OtsThreadPool :: Execução de tarefas em multi-threads - Delphi 10.3.3
Método de instalação:
1- Clique em: Component ?? Install Packages ?? Add
2- Selecione o arquivo: OtsThreadPool.bpl
Pronto!Exemplo de uso:
procedure OnExecuteThread(Sender: TObject);
begin
// Faça algo
end;Declare: OtsThreadPool.Util
procedure OnTerminateThread(Sender: TObject);
var
IdTrf: string;
begin
// Faça algo
// Recuperando a identificação da tarefa
IdTrf := (Sender as TOtsThreadPoolTask).Identity;
end;Declare: OtsThreadPool.RunTime
TaskManagerThread().NewTask( //
@OnExecuteThread, // Tarefa a ser executada
@OnTerminateThread, // Quando terminar, execute esse método, caso contrário use nil
'Tarefa id 001', // Identificação da tarefa, pode ser recuperada em OnTerminateThread
True, // Remove esta tarefa da lista ao iniciar? Padrão TRUE se for FALSE a tarefa é eterna
TThreadPriority.tpHighest // Prioridade da Thread
);
TaskManagerThread().ThreadCount := 1; // Pra iniciar precisa acrescentar o nº. de threads que deseja;Encerrar as tarefas por demanda
TaskManagerThread().Clear;
TaskManagerThread().ThreadCount := 0;
