FxInterruptWaitblock::~FxInterruptWaitblock(
    VOID
    )
{
    //
    // close the thread pool wait structure
    //
    if (m_Wait) {
        //
        // Make sure no event is registered.
        //
        ClearThreadpoolWait();

        //
        // Wait for all the callbacks to finish. 
        //
        WaitForOutstandingCallbackToComplete();

        //
        // close the wait 
        //
        CloseThreadpoolWait();

        m_Wait = NULL;
    }

    //
    // close event handle
    //
    if (m_Event) {
        CloseHandle(m_Event);
        m_Event = NULL;
    }
}
void CWaitThreadPools::CloseWaitThread()
{
	if (NULL==m_pWait) return;

	WaitForThreadpoolWaitCallbacks(m_pWait, TRUE);

	CloseThreadpoolWait(m_pWait);

	m_pWait = NULL;
}
FileOpLock::~FileOpLock()
{
	if (g_wait)
	{
		SetThreadpoolWait(g_wait, nullptr, nullptr);
		CloseThreadpoolWait(g_wait);
		g_wait = nullptr;
	}

	if (g_o.hEvent)
	{
		CloseHandle(g_o.hEvent);
		g_o.hEvent = nullptr;
	}

	if (g_hFile != INVALID_HANDLE_VALUE)
	{
		CloseHandle(g_hFile);
		g_hFile = INVALID_HANDLE_VALUE;
	}
}