public static SafeThreadHandle OpenThread(int threadId, int access)
{
SafeThreadHandle threadHandle = Interop.Kernel32.OpenThread(access, false, threadId);
int result = Marshal.GetLastWin32Error();
if (threadHandle.IsInvalid)
{
if (result == Interop.Errors.ERROR_INVALID_PARAMETER)
throw new InvalidOperationException(SR.Format(SR.ThreadExited, threadId.ToString(CultureInfo.CurrentCulture)));
throw new Win32Exception(result);
}
return threadHandle;
}
}