CloseHandle() private méthode

private CloseHandle ( IntPtr hObject ) : bool
hObject System.IntPtr
Résultat bool
        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);
                }
            }));
        }
Exemple #2
0
 protected override bool ReleaseHandle()
 {
     return(Win32.CloseHandle(base.handle));
 }