unit Myc.Signals.FMX; interface uses System.Classes, FMX.Controls, Myc.Signals; type TFMXSignalLink = class(TComponent, TSignal.ISubscriber) private [volatile] FInvalidated: Integer; procedure InvalidateControl; protected function Notify: Boolean; public constructor Create(AOwner: TControl); reintroduce; destructor Destroy; override; function Reset: Boolean; end; implementation uses System.SyncObjs; { TFMXSignalLink } constructor TFMXSignalLink.Create(AOwner: TControl); begin inherited Create(AOwner); FInvalidated := 0; end; destructor TFMXSignalLink.Destroy; begin TThread.RemoveQueuedEvents(InvalidateControl); inherited; end; procedure TFMXSignalLink.InvalidateControl; begin with TControl(Owner) do InvalidateRect(LocalRect); end; function TFMXSignalLink.Notify: Boolean; begin if TInterlocked.Exchange(FInvalidated, 1) = 0 then TThread.Queue(nil, InvalidateControl); exit( true ); end; function TFMXSignalLink.Reset: Boolean; begin Result := TInterlocked.Exchange(FInvalidated, 0) > 0; end; end.