CreateThreadpoolIo function

Creates a new I/O completion object.

Syntax

PTP_IO CreateThreadpoolIo(
  HANDLE                fl,
  PTP_WIN32_IO_CALLBACK pfnio,
  PVOID                 pv,
  PTP_CALLBACK_ENVIRON  pcbe
);

Parameters

fl

The file handle to bind to this I/O completion object.

pfnio

The callback function to be called each time an overlapped I/O operation completes on the file. For details, see IoCompletionCallback.

pv

Optional application-defined data to pass to the callback function.

pcbe

A TP_CALLBACK_ENVIRON structure that defines the environment in which to execute the callback. The InitializeThreadpoolEnvironment function returns this structure.

If this parameter is NULL, the callback executes in the default callback environment. For more information, see InitializeThreadpoolEnvironment.

Return Value

If the function succeeds, it returns a TP_IO structure that defines the I/O object. Applications do not modify the members of this structure.

If the function fails, it returns NULL. To retrieve extended error information, call GetLastError.

Remarks

To begin receiving overlapped I/O completion callbacks, call the StartThreadpoolIo function.

If the file handle bound to the I/O completion object has the notification mode FILE_SKIP_COMPLETION_PORT_ON_SUCCESS and an asychronous I/O operation returns immediately with success, the I/O completion callback function is not called and threadpool I/O notifications must be canceled. For more information, see CancelThreadpoolIo.

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or higher.

Requirements

   
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header threadpoolapiset.h (include Windows 7, Windows Server 2008 Windows Server 2008 R2, Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

CancelThreadpoolIo

CloseThreadpoolIo

StartThreadpoolIo

Thread Pools

WaitForThreadpoolIoCallbacks