public static SuspendThread ( |
||
threadHandle | A handle to the thread that is to be suspended. | |
Résultat | uint |
public static uint SuspendThread(SafeMemoryHandle threadHandle)
{
// Check if the handle is valid
HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle");
// Suspend the thread
var ret = NativeMethods.SuspendThread(threadHandle);
// If the function failed
if (ret == uint.MaxValue)
throw new Win32Exception("Couldn't suspend the thread.");
return ret;
}
/// <summary> /// Either suspends the thread, or if the thread is already suspended, has no effect. /// </summary> /// <returns>A new instance of the <see cref="FrozenThread" /> class. If this object is disposed, the thread is resumed.</returns> public FrozenThread Suspend() { if (!IsAlive) { return(null); } ThreadCore.SuspendThread(Handle); return(new FrozenThread(this)); }