event.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. Constructor TWin32Event.Create;
  18. Begin
  19. { create event handle }
  20. m_event := CreateEvent(Nil, True, False, Nil);
  21. { check event handle }
  22. If m_event = 0 Then
  23. Raise TPTCError.Create('could not create event');
  24. End;
  25. Destructor TWin32Event.Destroy;
  26. Begin
  27. { close handle }
  28. CloseHandle(m_event);
  29. Inherited Destroy;
  30. End;
  31. Procedure TWin32Event._set;
  32. Begin
  33. { set event }
  34. SetEvent(m_event);
  35. End;
  36. Procedure TWin32Event.reset;
  37. Begin
  38. { reset event }
  39. ResetEvent(m_event);
  40. End;
  41. Procedure TWin32Event.wait;
  42. Begin
  43. { wait for event }
  44. WaitForSingleObject(m_event, INFINITE);
  45. End;