Das Problem dabei ist folgendes: Das programm (der Thread) "friert" ein, bis die datei übertragen ist. erst dann gibt er die vollständige größe zurück:
Delphi-Quellcode:
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
stream: TFileStream;
income,filename,groesse, filename2: String;
i: Integer;
begin
income := AThread.Connection.ReadLn();
label1.Caption := income;
i := pos('|',income);
filename := copy(income,1,i-1);
label4.Caption := filename;
groesse := copy(income,i,length(income));
filename2 := extractfilename(filename);
label3.Caption := 'C:\'+filename2;
if FileExists('C:\'+filename2) then
DeleteFile('C:\'+filename2);
Stream := TFileStream.Create('C:\'+filename2,fmCreate);
while Athread.Connection.Connected do begin
Athread.Connection.ReadStream(Stream,-1,true);
label5.Caption := IntToStr(AThread.Connection.RecvBufferSize);
label2.Caption := IntToStr(stream.Size);
end;
FreeAndNil(Stream);
end;
Wie kann ich verhindern, dass der thread einfriert?
MfG Henry