ShootBlues.Win32.SuspendThread C# (CSharp) Méthode

SuspendThread() private méthode

private SuspendThread ( IntPtr hThread ) : uint
hThread System.IntPtr
Résultat uint
        public static extern uint SuspendThread(IntPtr hThread);

Usage Example

        public static Finally SuspendProcess(Process process)
        {
            var suspendedThreads = new HashSet <IntPtr>();

            foreach (ProcessThread thread in process.Threads)
            {
                var hThread = Win32.OpenThread(ThreadAccessFlags.SuspendResume, false, thread.Id);
                if (hThread != IntPtr.Zero)
                {
                    suspendedThreads.Add(hThread);
                    Win32.SuspendThread(hThread);
                }
                else
                {
                    Console.WriteLine("Could not open thread {0}", thread.Id);
                }
            }

            return(Finally.Do(() => {
                foreach (IntPtr hThread in suspendedThreads)
                {
                    Win32.ResumeThread(hThread);
                    Win32.CloseHandle(hThread);
                }
            }));
        }