question about threading

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

question about threading

Mesaj gönderen mia »

is threading can cause freezing on some windows ? because i believe its problem in my application . its working normal on windows 8 , but in windows 7 always freezes after thread execute many times . here is threading code

Kod: Tümünü seç

type
  TReadingThread = class(TThread)
  protected
    FConnection: TIdTCPConnection;
    FLogResult: TStrings;
    procedure Execute; override;
  public
    constructor Create(AConn: TIdTCPConnection; ALogResult: TStrings);
      reintroduce;
  end; 
thread Execute

Kod: Tümünü seç

procedure TReadingThread.Execute;
  Var
    strData: String;
  begin
    while not Terminated do
    begin
      try
        strData := FConnection.IOHandler.ReadLn;
        if strData <> '' then
        begin
          FLogResult.Add(strData);
        end;
      except
        on E: Exception do
        begin
          FConnection.Disconnect(False);
          if FConnection.IOHandler <> nil then
            FConnection.IOHandler.InputBuffer.Clear;
          Break;
        end;
      end;
      Sleep(10);
    end; // While
  end;

thread create

Kod: Tümünü seç

constructor TReadingThread.Create(AConn: TIdTCPConnection;
  ALogResult: TStrings);
begin
  FConnection := AConn;
  FLogResult := ALogResult;
  inherited Create(False);
end;
on client connect thread create

Kod: Tümünü seç

ListeningThread := TReadingThread.Create(TcpClient, commandsmemo.Lines);
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Cevapla