![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|
|
#1
|
|||
|
|||
|
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;
|
|
#2
|
||||
|
||||
|
Hola, el problema lo tienes en el constructor create, añade esta linea
Un Saludo. |
|
#3
|
|||
|
|||
|
Hola white_zombie. Te agradezco la gran ayuda que me has brindado. Me has solucionado el problema. Muchas Gracias.
Un saludo. |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
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 |
|