Platform SDK: DLLs, Processes, and Threads

BindIoCompletionCallback

The BindIoCompletionCallback function binds the specified file handle to the thread pool's I/O completion port. On completion of the I/O request, a non-I/O worker thread will execute the callback function.

BOOL BindIoCompletionCallback(
  HANDLE FileHandle,                         // handle to file
  LPOVERLAPPED_COMPLETION_ROUTINE Function,  // callback
  ULONG Flags                                // reserved
);

Parameters

FileHandle
[in] Handle to a file opened for overlapped I/O completion. This handle is returned by the CreateFile function, with FILE_FLAG_OVERLAPPED flag.
Function
[in] Pointer to the callback function to be executed in a non-I/O worker thread when the I/O operation is complete. This callback function must not call the TerminateThread function.

For more information about the completion routine, see FileIOCompletionRoutine.

Flags
Reserved; must be zero.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Be sure that the thread that initiates the asynchronous I/O request does not terminate before the request is completed. Also, if a function in a DLL is queued to a worker thread, be sure that the function has completed execution before the DLL is unloaded.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.

See Also

Processes and Threads Overview, Process and Thread Functions, FileIOCompletionRoutine, Thread Pooling