public static void TerminateThread(SafeMemoryHandle threadHandle, int exitCode)
{
// Check if the handle is valid
HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle");
// Terminate the thread
var ret = NativeMethods.TerminateThread(threadHandle, exitCode);
// If the function failed
if(!ret)
throw new Win32Exception("Couldn't terminate the thread.");
}