  THeoEMPVytezovaniDokThread = class(TThread)
   private
    FMainService: TService;
    FLock: TCriticalSection;
    FTermEvent: TEvent;
    FRunning: boolean;
    FTimer: THandle;
   protected
    procedure Execute; override;
    procedure TerminatedSet; override; // XE2+ only *
   public
    constructor Create (AOnTerminate: TNotifyEvent; AService: TService);
    destructor  Destroy; override;
    procedure ThreadTerminate;
  end;
