Thanks guys. Depend on your advices I made this:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
JvThread1.Execute(Self);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if not JvThread1.Terminated then
JvThread1.Terminate
;
end;
procedure TForm1.JvThread1Begin(Sender: TObject);
begin
ProcessingDialog := TProcessingDialog.Create('Heavy Task');
ProcessingDialog.Show;
end;
procedure TForm1.JvThread1CancelExecute(CurrentThread: TJvThread);
begin
JvThread1Finish(Self);
end;
procedure TForm1.JvThread1Execute(Sender: TObject; Params: Pointer);
var
I: Integer;
begin
for I := 0 to 100000 do
begin
TForm1(Params).Value := I;
JvThread1.Synchronize(TForm1(Params).UpdateStatus);
if JvThread1.Terminated then
Break
;
end;
end;
procedure TForm1.JvThread1Finish(Sender: TObject);
begin
ProcessingDialog.Free;
end;
procedure TForm1.UpdateStatus;
begin
Caption := IntToStr(Value);
end;
Yes, I know, is completely lame, because uses component. But is simple
So, it working if I just open dialog, but I want to modal dialog (to lock
access to interface), but when ShowModal(), thread don't execute. There is solution on this?