' UInteger output
Declare Function GetExitCodeThread Lib "kernel32.dll" (ByVal hThread As IntPtr, ByRef lpExitCode As UInteger) As Boolean
' IntPtr output
Declare Function GetExitCodeThread Lib "kernel32.dll" (ByVal hThread As IntPtr, ByVal lpExitCode As IntPtr) As Boolean
Sample Code:
uint dwOut = 0;
while (GetExitCodeThread(hThread, out dwOut))
{
if (dwOut != 0x103)
break;
Thread.Sleep(10); // Don't cook our CPU
}
Console.WriteLine("Thread exit code: {0}", dwOut);