Autor Beitrag
olliistmeinname
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 17.05.04 14:48 
Hi !
Ich schreibe an einem Prog bei dem ein Bild über das internet versendet wird.
Das funktioniert auch.
Hier erstmal der Code !

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.Button1Click(Sender: TObject);
var
stream :tmemorystream;
jpeg : tjpegimage;
bitmap:tbitmap;
begin

    jpeg := tjpegimage.Create;
    Stream := tmemorystream.Create;
    bitmap := tbitmap.Create;
    try
    idtcpclient1.Host := edit1.Text;
    idtcpclient1.Connect(900);
    IdtCPClient1.ReadStream(Stream, 1, true); // Stream empfangen
    stream.Seek(0, soFromBeginning);
    jpeg.LoadFromStream(stream);
    bitmap.Assign(jpeg);
    image1.Picture.Bitmap.Assign(bitmap);
    finally
    stream.Free;
    jpeg.Free;
    bitmap.Free;
    end;

end;



Das Problem ist,dass sich das Form für 1-2 Sekunden in dem moment nicht bewegen lässt. (Also es ist eingefroren trotz 0% Auslastung der CPU).

Kann man dies umgehen ?

MFG Olli
Kann man dies irgendwie umgehen ?

*edit*
Einen Tippfehler beseitigt :wink:

_________________
Olliistmeinname und bin da für jede Dame
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Mo 17.05.04 15:15 
Soweit ich mich erinnere gibt es bei Indy auch eine Komponente namens IdAntiFreeze, welche dein Problem lösen könnte:

Die Indy Hilfedatei hat folgendes geschrieben:

TIdAntiFreeze = class(TIdAntiFreezeBase)

Description

Indy works on the blocking model. That is when calls are made to Indy the do not return until they are complete. If calls are made in the main thread this will cause the Application User Interface to "freeze" during Indy calls. TIdAntiFreeze counter acts this effect. TIdAntiFreeze allows Indy subsystem to make process Application message calls so that Windows messages continue to be executed while Indy blocking socket calls are in effect.

Only one TIdAntiFreeze can be active in an application. If another instance already exists, an exception is raised. TIdAntiFreezeBase uses the global variable GAntiFreeze, declared in the TIdAntiFreezeBase unit, to determine if another instance has already been created.

Note: GAntiFreeze is not assigned if an instance is added in the form designer (during design time).

Note: The TIdAntiFreeze.pas unit must NOT appear in the uses clause of any Indy or descendant unit. This unit is linked in an application when the component is placed on a Form. This is done to preserve isolation from the Forms.pas and QForms.pas units.

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!