Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 07-06-2016
Ramsay Ramsay is offline
Miembro
NULL
 
Registrado: ene 2016
Posts: 104
Poder: 11
Ramsay Va por buen camino
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 :

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
const
  MSG_START = 1;
var
  iTask, numTasks, ReadTimeout: integer;
  url: string;
begin
  numTasks := 100;

  url := 'http://localhost/';
  ReadTimeout := 1000;

  for iTask := 1 to numTasks do
  begin
    Application.ProcessMessages;

    CreateTask(
      procedure(const task: IOmniTask)
      var
        ReadTimeout: integer;
        IdHTTP: TIdHTTP;
        url: string;
        ReturnValue:integer;
      begin
        task.Comm.Send(MSG_START);

        url := task.Param['Url'].AsString;
        ReadTimeout := task.Param['ReadTimeout'].AsInteger;
        ReturnValue := 0;

        IdHTTP := TIdHTTP.Create(nil);
        try
          IdHTTP.ReadTimeout := ReadTimeout;
          IdHTTP.Get(url);
          ReturnValue := 1;
        finally
          IdHTTP.Free;
        end;

        // some task workload
        // Sleep(sleepTime);
      end).OnMessage(
      procedure(const task: IOmniTaskControl; const msg: TOmniMessage)
      var
        taskNumber: integer;
      begin
        if msg.MsgID = MSG_START then
        begin
          taskNumber := task.Param['ReadTimeout'].AsInteger;

          LogPoolStatus(Format('task %d / %d start', [taskNumber,
            task.UniqueID]));
        end;
      end).OnTerminated(
      procedure(const task: IOmniTaskControl)
      begin
        // Aca muestro el ReturnValue
        LogPoolStatus(Format('task id %d terminated', [task.UniqueID]));
      end).SetParameter('url', url).SetParameter('ReadTimeout', ReadTimeout)
      .Unobserved.Schedule;
  end;

  // wait all finished
  while GlobalOmniThreadPool.CountExecuting +
    GlobalOmniThreadPool.CountQueued > 0 do
    Application.ProcessMessages;

  // all task completed
  LogPoolStatus('ALL DONE');
end;

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.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

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


La franja horaria es GMT +2. Ahora son las 20:49:26.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi