Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 13-04-2009
zajoma zajoma is offline
Miembro
 
Registrado: feb 2006
Posts: 32
Poder: 0
zajoma Va por buen camino
He creado un hilo elemental de la forma
Código:
uses ... , SyncObjs, ...;
 
type
  TMiHilo = class( TThread )
  private
    FinternalData:TStringList;
    FEvent:TEvent;
  public
    constructor Create( CreateSuspended:boolean );
    function LeerCadena( timeout:integer ):string;
    procedure Execute(); override;
 
    property Event:TEvent read FEvent;
  end;
 
constructor TMiHilo.Create( CreateSuspended:boolean );
begin
  FInternalData := TStringList.Create();
  FEvent := TEvent.Create( nil, false, false, '' );
end;
 
function TMiHilo.LeerCadena( timeout:integer ):string;
var
  res:TWaitResult;
begin
  if ( timeout = 0 ) then res := FEvent.WaitFor( INFINITE )
  else res := FEvent.WaitFor( timeout );
 
  if ( res = wrSignaled ) then begin
    result := FInternalData[0];
    FInternalData.Delete(0);
    if FInternalData.Count > 0 then FEvent.SetEvent;
  end else
  if ( res = wrTimeout ) then result := 'timeout' else result := 'error';
end;
 
procedure TMiHilo.Execute();
begin
  while not Self.Terminated do begin
    ReadDataFromFile();
    FEvent.SetEvent;
    Sleep(1000);
  end;
end;
Un saludo y gracias por el interés.
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
Ayuda con Hilos Dark_RavenM Varios 14 09-07-2010 23:46:44
Hilos johurgi Varios 2 16-07-2007 10:57:08
ver hilos Cosgaya Varios 1 07-06-2005 20:35:16
Hilos con COM urush30 Varios 0 21-09-2004 10:07:37
problema con hilos weke Varios 1 13-07-2004 09:39:27


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


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