public static void SetThreadContext(SafeMemoryHandle threadHandle, ThreadContext context) { // Check if the handle is valid HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle"); // Set the thread context if(!NativeMethods.SetThreadContext(threadHandle, ref context)) throw new Win32Exception("Couldn't set the thread context."); }