AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi TThread: Daten von Mainthread holen --> Synchronize notwendig?
Thema durchsuchen
Ansicht
Themen-Optionen

TThread: Daten von Mainthread holen --> Synchronize notwendig?

Ein Thema von Helmi · begonnen am 18. Dez 2024 · letzter Beitrag vom 18. Dez 2024
 
Benutzerbild von jaenicke
jaenicke
Online

Registriert seit: 10. Jun 2003
Ort: Berlin
10.135 Beiträge
 
Delphi 12 Athens
 
#5

AW: TThread: Daten von Mainthread holen --> Synchronize notwendig?

  Alt 18. Dez 2024, 08:29
Du musst alle Zugriffe entsprechend absichern. Beispiel:
Delphi-Quellcode:
// Hauptthread:
TFormA = class(TForm)
private
  FValue: string;
...
end;

procedure TFormA.Example;
begin
  TMonitor.Enter(Self);
  try
    FValue := 'Test';
  finally
    TMonitor.Exit(Self);
  end;
end;

// vom Thread aufgerufen:
function TFormA.ThreadCallback: string;
begin
  TMonitor.Enter(Self);
  try
    Result := FValue;
  finally
    TMonitor.Exit(Self);
  end;
end;
Sebastian Jänicke
AppCentral
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz