windows-nt/Source/XPSP1/NT/net/homenet/alg/alg_ftp/regevent.cpp

72 lines
1.2 KiB
C++
Raw Normal View History

2020-09-26 03:20:57 -05:00
#include "precomp.h"
#include "list.h"
CRegisteredEventList g_RegisteredEventList;
VOID
NhInitializeCallBack(VOID)
{
return;
}
//
//
//
VOID
NhUnRegisterEvent(HANDLE WaitHandle)
{
HANDLE hEvent;
UnregisterWaitEx(WaitHandle,INVALID_HANDLE_VALUE);
g_RegisteredEventList.Remove(WaitHandle,&hEvent);
CloseHandle(hEvent);
return;
}
//
//
//
VOID
NhEventCallBackFunction(
PVOID Context,
BOOLEAN TimerOrWait
)
{
HANDLE hEvent = (HANDLE)Context;
HANDLE WaitHandle;
VOID *Context1;
VOID *Context2;
EVENT_CALLBACK CallBack;
g_RegisteredEventList.Remove(&WaitHandle,hEvent,&CallBack,&Context1,&Context2);
CloseHandle(hEvent);
(*CallBack)(TimerOrWait,Context1,Context2);
return;
}
//
//
//
HANDLE
NhRegisterEvent(
HANDLE hEvent,
EVENT_CALLBACK CallBack,
VOID* Context,
VOID* Context2,
ULONG TimeOut
)
{
VOID *nContext;
HANDLE WaitHandle = NULL;
BOOL Err;
Err = RegisterWaitForSingleObject(&WaitHandle,hEvent,NhEventCallBackFunction,(PVOID)hEvent,TimeOut,
WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE);
if (Err)
g_RegisteredEventList.Insert(WaitHandle,hEvent,CallBack,Context,Context2);
else
WaitHandle = NULL;
return WaitHandle;
}