HI.
I hope someone can give me a hint here.
Printque is a Form created in the Main Thread, just before calling this thread.
Its Formcreate contains this line:
Tstuckthread.Create(Tprintqueue(self),printernames);
The problem is in the showform procedure at the line .A.show
It gives no error, but the app becomes unresponsive. The main form is hidden, and I have to stop the app.I
Tstuckthread= class(TThread)
private
FForm: TFORM;
L:tSTRINGLIST;
function STUCK(title:string;l:Tstringlist): boolean;
procedure listjobs(allprinters: string);
protected
public
constructor Create(ownerForm:TFORM;printernames:string; ARUNS: INTEGER=0);
destructor Destroy; override;
procedure Execute(); override;
procedure showform;
published
end;
constructor Tstuckthread.Create(ownerForm: TFORM;printernames: string;ARUNS: INTEGER=0);
begin
L:=tSTRINGLIST.CREATE;
FForm:= ownerForm;
Self.FreeOnTerminate := True;
inherited Create;
end;
destructor Tstuckthread.Destroy;
begin
inherited;
L.FREE;
end;
procedure Tstuckthread.Execute;
begin
done :=FALSE;
while not Terminated AND NOT done do begin
<get printjobs list and save it in L......>
if L.count>0 then BEGIN /// fine HERE
Tprintqueue(FForm).MEMO1.LINES.ASSIGN(L); // fine HERE
Synchronize(SHOWForm);
SLEEP(500);
END;
DONE:=TRUE;
end;
end;
And here is the showform() procedure;
procedure Tstuckthread.showform;
VAR
A: Tprintqueue;
begin
A:=Tprintqueue(FForm);
TRY
IF NOT A.VISIBLE THEN
A.show; // PROBLEM HERE.
EXCEPT
a.free;// 4 testing. It never gets there.
END;