Einzelnen Beitrag anzeigen

Frankieboy82

Registriert seit: 21. Mai 2008
12 Beiträge
 
#5

Re: TThreadList benutzen um Variablen im Hauptthread zu schü

  Alt 21. Mai 2008, 09:54
OK, hier mal die Implementation der beiden wichtigen Prozeduren aus TWorkThread:

Delphi-Quellcode:
procedure TWorkThread.FetchInput_SHARED;
begin
  if FOwner.FInputLines_SHARED.Count > 0 then
  begin
    FInputLines_SHARED.Assign(FOwner.FInputLines_SHARED);
    FOwner.FInputLines_SHARED.Clear;
  end;
end;
Wie man sieht, passiert nicht viel: Enthält der Puffer der VC Strings, dann werden sie übernommen und danach gelöscht.


Delphi-Quellcode:
procedure TWorkThread.SendOutput_SHARED;
begin
  if Assigned(FOwner.FOutputLines_SHARED) then
      begin
        FOwner.FOutputLines_SHARED.BeginUpdate;
        if FOwner.FOutputLines_SHARED.Count = 0 then
          begin
            if (FOutputType = otEntireLine) then
              FOwner.FOutputLines_SHARED.Add(FOutputStr)
            else
              FOwner.FOutputLines_SHARED.Text := FOutputStr;
          end
        else
          begin
            // change the way to add by last addstring type
            if FLineBeginned then
              FOwner.FOutputLines_SHARED[FOwner.FOutputLines_SHARED.Count - 1] := FOutputStr
            else
              FOwner.FOutputLines_SHARED.Add(FOutputStr);
          end;
        FOwner.FOutputLines_SHARED.EndUpdate;
      end;
  FLineBeginned := (FOutputType = otBeginningOfLine);
end;
Das hier ist etwas komplizierter, ich habe es aus einem anderen Quelltext übernommen, und muss es noch vereinfachen.
  Mit Zitat antworten Zitat