Binarysharp.MemoryManagement.Helpers.HandleManipulator.HandleToThreadId C# (CSharp) Method

HandleToThreadId() public static method

Converts an handle into a thread id assuming this is a thread handle.
public static HandleToThreadId ( SafeMemoryHandle threadHandle ) : int
threadHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A valid handle to an opened thread.
return int
        public static int HandleToThreadId(SafeMemoryHandle threadHandle)
        {
            // Check if the handle is valid
            ValidateAsArgument(threadHandle, "threadHandle");

            // Find the thread id
            var ret = NativeMethods.GetThreadId(threadHandle);

            // If the thread id is valid
            if (ret != 0)
                return ret;

            //Else the function failed, throws an exception
            throw new Win32Exception("Couldn't find the thread id of the specified handle.");
        }