Skip to main content
IoCompletionCallback callback function

Applications implement this callback if they call the StartThreadpoolIo function to start a worker thread for the I/O completion object.

The PTP_WIN32_IO_CALLBACK type defines a pointer to this callback function. IoCompletionCallback is a placeholder for the application-defined function name.


VOID CALLBACK IoCompletionCallback(
  _Inout_     PTP_CALLBACK_INSTANCE Instance,
  _Inout_opt_ PVOID                 Context,
  _Inout_opt_ PVOID                 Overlapped,
  _In_        ULONG                 IoResult,
  _In_        ULONG_PTR             NumberOfBytesTransferred,
  _Inout_     PTP_IO                Io


Instance [in, out]

A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.

This structure can be passed to one of the following functions:

Context [in, out, optional]

The application-defined data.

Overlapped [in, out, optional]

A pointer to a variable that receives the address of the OVERLAPPED structure that was specified when the completed I/O operation was started.

IoResult [in]

The result of the I/O operation. If the I/O is successful, this parameter is NO_ERROR. Otherwise, this parameter is one of the system error codes.

NumberOfBytesTransferred [in]

The number of bytes transferred during the I/O operation that has completed.

Io [in, out]

A TP_IO structure that defines the I/O completion object that generated the callback.

Return value

This function does not return a value.


If the file handle bound to the I/O completion object has the notification mode FILE_SKIP_COMPLETION_PORT_ON_SUCCESS and an asynchronous 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.


Minimum supported client

Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 [desktop apps | UWP apps]


WinBase.h on Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2 (include Windows.h);
Threadpoolapiset.h on Windows 8 and Windows Server 2012

See also

Thread Pools