![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#1
|
|||
|
|||
|
Problema con hilos
Hola a todos.
Estoy intentando, con Delphi 7, Crear una aplicación con hilos pero cuando lo ejecuto me sale un error que dice: Project Project1.exe raised exception class EThread with message 'Thread Error: Controlador no válido (6)'. Process stopped. Use Step or Run to continue. A qué puede ser debido. Un saludo. |
|
#2
|
||||
|
||||
|
Hola,
El mensaje de error está muy bien puesto, pero, me temo que sea preciso algo de código para encontrar el posible problema. Si pudieras concretar el error en unas cuantas líneas de código y pudieras copiarlas aquí... igual alguien estaría en disposición de echarte una mano. ![]() |
|
#3
|
|||
|
|||
|
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;
|
|
#4
|
||||
|
||||
|
Hola, el problema lo tienes en el constructor create, añade esta linea
Un Saludo. |
|
#5
|
|||
|
|||
|
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 |
|