FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
MultiThread cada 5 Thread
Hola , estoy usando multithread para comprobar paginas en un array largo , el tema es que funciona bien y todo , pero tendria que ser cada 10 o 5 Thread porque sino me consume mucho , me refiero a que cargue 5 thread y cuando terminen continue con otros 5 , el codigo de la unit de los threads.
Form
El array real es mas largo. ¿ Como deberia hacer esto ? |
#2
|
||||
|
||||
La estrategia general es crear los 4 threads (lo que hace un "ThreadPool") al inicio y dejarlos *vivos*. Luego usas un un Queue que es el medio de comunicación, y lo usas para enviar y recibir los datos. Asi es mas simple.
https://stackoverflow.com/questions/...ueue-in-delphi La libreria de Omnithread -que he usado y tiene eso y mucho mas- Aqui lo hacen con envio de mensajes de windows, que tambien te podria servir): http://delphi.about.com/od/kbthread/...ry-example.htm
__________________
El malabarista. |
#3
|
|||
|
|||
Hola , gracias por responder , esta todo perfecto y mas facil , solo me falta poder dar una respuesta al evento OnTerminate() por parte del CreateTask()
El codigo :
Me refiero a poder usar la variable ReturnValue que tenia en el codigo viejo en el Create() , si el idhttp sale bien entonces retorna 1 , si sale mal 0 , y poder leer la variable ReturnValue en el evento OnTerminated.Ya probe manualmente pero parece que si uso la variable en el Create() no llega a leerse en el OnTerminated(). Solo me falta ese pequeño detalle , espero haberme explicado bien ,ya casi termino. ¿ Como deberia hacerlo ? Última edición por Ramsay fecha: 07-06-2016 a las 00:27:45. |
#4
|
|||
|
|||
Hay algo como la libreria "Omnithread" para Delphi 7?
Gracias |
#5
|
||||
|
||||
Pues es lo que tienes con LogPoolStatus: Le estas enviando a ese metodo cada resultado. Hay tienes que, un Memo? Pues sea un memo o una lista vas acumulando los resultados en una estructura, al final, tienes algo como Memo.Lines <- ese es tu resultado!
__________________
El malabarista. |
#6
|
|||
|
|||
Si ,gracias por responder , tambien vi que se puede enviar un msg al onmessage() con los datos pero no al onterminate() , pero algo que no entiendo es cuando el proceso esta hecho en cada thread , parece que todo puede terminar en el createtask() , ¿ entonces para que uso onmessage() y onterminate() ? ¿ todo termina en el onmessage() ? , es que no entiendo estos eventos ...
|
#7
|
||||
|
||||
__________________
El malabarista. |
#8
|
|||
|
|||
Si , ya los lei por eso pregunto la duda , uso createtask() con el codigo a usar y muestro el resultado en onmessage() , ¿ eso seria lo correcto ?
|
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Multithread | angelp4492 | Varios | 5 | 15-05-2012 09:09:47 |
Duda en Sockets MultiThread | JesusRamirez | Internet | 3 | 21-08-2010 06:54:13 |
componente MultiFileDownloader multithread para bajar http y ftp en indy 10 | softx2009 | Internet | 3 | 18-01-2010 16:17:47 |
Thread | Paulao | Varios | 1 | 09-05-2008 00:42:34 |
Thread bendito thread...se me pierde la ventana | Seba.F1 | API de Windows | 5 | 02-02-2006 00:16:30 |
|