unit thread_communicator; { This file is part of AMIProxyPal. AMIProxyPal is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Foobar. If not, see . } {$mode objfpc}{$H+} interface uses Classes, SysUtils, syncobjs ; type TThreadCommunicator = class(TObject) private FCritical: TCriticalSection; FMsg: string; procedure SetMsg( const AValue: string) ; public // ---> methods procedure Lock; procedure Unlock; // ---> Properties property Msg: string read FMsg write SetMsg; // ---> Construction Ahead constructor Create; destructor Destroy; override; end; implementation { TThreadCommunicator } procedure TThreadCommunicator.SetMsg( const AValue: string) ; begin if FMsg= AValue then exit; FMsg:= AValue; end; procedure TThreadCommunicator.Lock; begin FCritical.Enter; end; procedure TThreadCommunicator.Unlock; begin FCritical.Leave; end; constructor TThreadCommunicator.Create; begin FCritical := TCriticalSection.Create; end; destructor TThreadCommunicator.Destroy; begin FCritical.free; inherited Destroy; end; end.