HandleWaitThreadUnit.pas 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. This Delphi unit is part of TIGCC.
  3. Copyright (C) 2000-2004 Sebastian Reichelt
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. }
  16. unit HandleWaitThreadUnit;
  17. interface
  18. uses
  19. SysUtils, Classes, Windows, Forms, Controls;
  20. type
  21. THandleWaitThread = class(TThread)
  22. private
  23. FHasTerminated: Boolean;
  24. FWaitHandle: THandle;
  25. protected
  26. procedure Execute; override;
  27. public
  28. property WaitHandle: THandle read FWaitHandle;
  29. property HasTerminated: Boolean read FHasTerminated;
  30. constructor Create(WaitHandle: THandle);
  31. end;
  32. implementation
  33. { THandleWaitThread }
  34. constructor THandleWaitThread.Create(WaitHandle: THandle);
  35. begin
  36. inherited Create (True);
  37. FHasTerminated := False;
  38. FreeOnTerminate := False;
  39. FWaitHandle := WaitHandle;
  40. Resume;
  41. end;
  42. procedure THandleWaitThread.Execute;
  43. begin
  44. while (not Terminated) and (WaitForSingleObject (FWaitHandle, 1000) = Wait_TimeOut) do;
  45. FHasTerminated := True;
  46. end;
  47. end.