Thema: Delphi Thread freezed - Warum??

Einzelnen Beitrag anzeigen

Sereby

Registriert seit: 31. Mär 2008
91 Beiträge
 
#3

Re: Thread freezed - Warum??

  Alt 7. Jan 2010, 12:30
nein das mit waitfor ist im bereits erstellten thread. Der andere verwaltungsthread ist aber auf die selbe art erzeugt worden bloss ohne WaitFor.

etwas mehr debuggen hat zu tage gebracht, dass es an Synchronize liegt?!?!!!!
die delphi ide meint dass der Haupt-Thread durch nen SendMessage aufgehalten wird..
ich rufe in dem erstellten Thread die procedure SetTextOf auf welche ich selbst definiert habe

wenn ich im Thread folgendes aufrufe, dann kommt der nicht bis zum ende!
Delphi-Quellcode:
...
begin
  SetTextOf(FDebugCtrl,'',False,True);
  SetTextOf(FDebugCtrl,'',False,True);
  SetTextOf(FDebugCtrl,'',False,True);
  SetTextOf(FDebugCtrl,'',False,True);
end;
FDebugCtrl wurde im Workerthread an den AufgebenThread übergeben und entspricht GUIApply.DebugText (GUIApply ist ein frame)

Delphi-Quellcode:
procedure TGUIThreadHelper.SetTextOf(Element: TControl; Text: String;
  AddTime, ReplaceText: Boolean; FontStyles: TFontStyles;
  FontSize: Integer; FontColor: TColor);
begin
  FDstCtrl := Element;
  FTmpStr := Text;
  FReplace := ReplaceText;
  FFontStyles := FontStyles;
  FTmpBool := AddTime;
  FTmpInt := FontSize;
  FFontColor := FontColor;
  Synchronize(SetText);
end;

procedure TGUIThreadHelper.SetText;
begin
  if (FDstCtrl = nil) then Exit;
  if (FDstCtrl is TsRichEdit) then
  begin
    if FReplace then
      TsRichEdit(FDstCtrl).Text := FTmpStr
    else
    begin
      if TsRichEdit(FDstCtrl).Hint = 'logthen
      begin
        //TsRichEdit(DstCtrl).SelStart := TsRichEdit(DstCtrl).SelLength; //oben anhängen
        //nach unten jumpen
        TsRichEdit(FDstCtrl).SelStart := Length(TsRichEdit(FDstCtrl).Text); //geschmeidig unten anhängen und gleich hinspringen

        //Zeit absplitten damit nur der rest gestyled wird
        if FTmpBool then
          TsRichEdit(FDstCtrl).SelText := FormatDateTime('hh:mm:ss.zzz', Now) + ' >> ';

        //nach unten jumpen
        TsRichEdit(FDstCtrl).SelStart := Length(TsRichEdit(FDstCtrl).Text); //geschmeidig unten anhängen und gleich hinspringen

        //stylen und hinzufügen
        TsRichEdit(FDstCtrl).SelAttributes.Style := FFontStyles;
        TsRichEdit(FDstCtrl).SelAttributes.Color := FFontColor;
        TsRichEdit(FDstCtrl).SelAttributes.Size := FTmpInt;
        TsRichEdit(FDstCtrl).SelText := FTmpStr;
      end else
        TsRichEdit(FDstCtrl).Text := TsRichEdit(FDstCtrl).Text + FTmpStr;
    end;
    TsRichEdit(FDstCtrl).Refresh;
  end else if (FDstCtrl is TEdit) or (FDstCtrl is TsEdit) then
  begin
    if FReplace then TEdit(FDstCtrl).Text := FTmpStr
    else TEdit(FDstCtrl).Text := TEdit(FDstCtrl).Text + FTmpStr;
    TEdit(FDstCtrl).Font.Style := FFontStyles;
    TEdit(FDstCtrl).Font.Color := FFontColor;
    TEdit(FDstCtrl).Font.Size := FTmpInt;
    TEdit(FDstCtrl).Refresh;
  end else if (FDstCtrl is TButton) or (FDstCtrl is TsButton) then
  begin
    if FReplace then TButton(FDstCtrl).Caption := FTmpStr
    else TButton(FDstCtrl).Caption := TButton(FDstCtrl).Caption + FTmpStr;
    TButton(FDstCtrl).Font.Style := FFontStyles;
    TButton(FDstCtrl).Font.Color := FFontColor;
    TButton(FDstCtrl).Font.Size := FTmpInt;
    TButton(FDstCtrl).Refresh;
  end else if (FDstCtrl is TLabel) or (FDstCtrl is TsLabel) then
  begin
    if FReplace then TLabel(FDstCtrl).Caption := FTmpStr
    else TLabel(FDstCtrl).Caption := TLabel(FDstCtrl).Caption + FTmpStr;
    TLabel(FDstCtrl).Font.Style := FFontStyles;
    TLabel(FDstCtrl).Font.Color := FFontColor;
    TLabel(FDstCtrl).Font.Size := FTmpInt;
    TLabel(FDstCtrl).Refresh;
  end else if (FDstCtrl is TsGauge) then
  begin
    if FReplace then
      TsGauge(FDstCtrl).Hint := FTmpStr
    else
      TsGauge(FDstCtrl).Hint := TsGauge(FDstCtrl).Hint + FTmpStr;
  end else if (FDstCtrl is TComboBox) or (FDstCtrl is TsComboBox) then
  begin
    if FReplace then TComboBox(FDstCtrl).Items.Text := FTmpStr
    else TComboBox(FDstCtrl).Items.Text := TComboBox(FDstCtrl).Items.Text + FTmpStr;
    TComboBox(FDstCtrl).Font.Style := FFontStyles;
    TComboBox(FDstCtrl).Font.Color := FFontColor;
    TComboBox(FDstCtrl).Font.Size := FTmpInt;
    TComboBox(FDstCtrl).Refresh;
  end else if (FDstCtrl is TRadioButton) or (FDstCtrl is TsRadioButton) then
  begin
    if FReplace then TRadioButton(FDstCtrl).Caption := FTmpStr
    else TRadioButton(FDstCtrl).Caption := TRadioButton(FDstCtrl).Caption + FTmpStr;
    TRadioButton(FDstCtrl).Font.Style := FFontStyles;
    TRadioButton(FDstCtrl).Font.Color := FFontColor;
    TRadioButton(FDstCtrl).Font.Size := FTmpInt;
    TRadioButton(FDstCtrl).Refresh;
  end else if (FDstCtrl is TCheckBox) or (FDstCtrl is TsCheckBox) then
  begin
    if FReplace then TCheckBox(FDstCtrl).Caption := FTmpStr
    else TCheckBox(FDstCtrl).Caption := TCheckBox(FDstCtrl).Caption + FTmpStr;
    TCheckBox(FDstCtrl).Font.Style := FFontStyles;
    TCheckBox(FDstCtrl).Font.Color := FFontColor;
    TCheckBox(FDstCtrl).Font.Size := FTmpInt;
    TCheckBox(FDstCtrl).Refresh;
  end;
end;
- TsRichedit ist eine Komponente aus dem AlphaControls Package
- WorkerThread sowie die Aufgaben ist abgeleitet von TGUIThreadHelper und der von TThread
  Mit Zitat antworten Zitat