Binarysharp.MemoryManagement.Threading.ThreadCore.ResumeThread C# (CSharp) Méthode

ResumeThread() public static méthode

Decrements a thread's suspend count. When the suspend count is decremented to zero, the execution of the thread is resumed.
public static ResumeThread ( SafeMemoryHandle threadHandle ) : uint
threadHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the thread to be restarted.
Résultat uint
        public static uint ResumeThread(SafeMemoryHandle threadHandle)
        {
            // Check if the handle is valid
            HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle");

            // Resume the thread
            var ret = NativeMethods.ResumeThread(threadHandle);

            // If the function failed
            if (ret == uint.MaxValue)
                throw new Win32Exception("Couldn't resume the thread.");

            return ret;
        }

Usage Example

        /// <summary>
        ///     Resumes a thread that has been suspended.
        /// </summary>
        public void Resume()
        {
            // Check if the thread is still alive
            if (!IsAlive)
            {
                return;
            }

            // Start the thread
            ThreadCore.ResumeThread(Handle);

            // Start a task to clean the memory used by the parameter if we created the thread
            if (_parameter != null && !_parameterCleaner.IsCompleted)
            {
                _parameterCleaner.Start();
            }
        }