Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions win32/src/win32event.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

%module win32event // A module which provides an interface to the win32 event/wait API

%{
#define _WIN32_WINNT 0x0501
%}

%include "typemaps.i"
%include "pywin32.i"

Expand Down Expand Up @@ -55,6 +51,13 @@

#define INFINITE INFINITE

#define CREATE_WAITABLE_TIMER_MANUAL_RESET CREATE_WAITABLE_TIMER_MANUAL_RESET
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION CREATE_WAITABLE_TIMER_HIGH_RESOLUTION

#define TIMER_ALL_ACCESS TIMER_ALL_ACCESS
#define TIMER_MODIFY_STATE TIMER_MODIFY_STATE
#define TIMER_QUERY_STATE TIMER_QUERY_STATE

#define QS_ALLEVENTS QS_ALLEVENTS // An input, WM_TIMER, WM_PAINT, WM_HOTKEY, or posted message is in the queue.

#define QS_ALLINPUT QS_ALLINPUT // Any message is in the queue.
Expand Down Expand Up @@ -130,6 +133,16 @@ PyHANDLE CreateWaitableTimer(
BOOL bManualReset, // @pyparm bool|ManualReset||True for manual reset timer, or False to create a synchronization timer
TCHAR * INPUT_NULLOK // @pyparm str|TimerName||Timer object name, or None
);

// @pyswig <o PyHANDLE>|CreateWaitableTimerEx|Creates or opens a waitable timer object and returns a handle to the object
// @rdesc The result is a handle to the object
// @pyseeapi CreateWaitableTimerEx
PyHANDLE CreateWaitableTimerEx(
SECURITY_ATTRIBUTES *TimerAttributes, // @pyparm <o PySECURITY_ATTRIBUTES>|TimerAttributes||Specifies inheritance and security descriptor for object, or None for defaults
TCHAR *INPUT_NULLOK, // @pyparm str|TimerName||Timer object name, or None
DWORD dwFlags, // @pyparm int|Flags||Flags
DWORD dwDesiredAccess // @pyparm int|DesiredAccess||The access mask for the timer object
);
#endif // MS_WINCE


Expand Down
12 changes: 12 additions & 0 deletions win32/test/test_win32event.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ def testWaitableFire(self):
rc = win32event.WaitForSingleObject(h, 1000)
self.assertEqual(rc, win32event.WAIT_OBJECT_0)

def testCreateWaitableTimerEx(self):
h = win32event.CreateWaitableTimerEx(
None,
None,
win32event.CREATE_WAITABLE_TIMER_HIGH_RESOLUTION,
win32event.TIMER_ALL_ACCESS,
)
dt = -160 # 160 ns.
win32event.SetWaitableTimer(h, dt, 0, None, None, 0)
rc = win32event.WaitForSingleObject(h, 1000)
self.assertEqual(rc, win32event.WAIT_OBJECT_0)

def testWaitableTrigger(self):
h = win32event.CreateWaitableTimer(None, 0, None)
# for the sake of this, pass a long that doesn't fit in an int.
Expand Down