_endthreadex

De RAD Studio
Aller à : navigation, rechercher

Remonter à process.h - Index


Header File

process.h

Category

Process Control Routines

Prototype

void _endthreadex(unsigned thread_retval);

Description

Terminates execution of the current thread by calling the ExitThread API, but without closing the handle. The thread must have been created by an earlier call to _beginthreadex. The runtime library will call _endthreadex autotmatically, when your thread function terminates. _endthreadex receives the return value of your thread function in thread_retval, and will pass it along to the Win32 ExitThread API.

Remarque :  Note: Performs the same operation as _endthread(), but does not close the thread handle.

Return Value

None.

Example

#include <process.h>
#include <windows.h>
unsigned int _stdcall thread_func(void*)
{
  /* Print a string and close the thread from inside */
  printf("Running on another thread!\n");
  _endthreadex(0);
}

int _tmain(int argc, _TCHAR* argv[])
{
  /* Start the thread and wait */
  unsigned int threadId;
  _beginthreadex(NULL, 4096, thread_func, NULL, 0, &threadId);
  Sleep(100);

  return 0;
}