static void ResumeAllThreads(SetupDesktop.CefProcess item) { foreach (ProcessThread thread in item.Proc.Threads) { var pOpenThread = NativeMethods.OpenThread(NativeMethods.ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); if (pOpenThread == IntPtr.Zero) { break; // continue; } //StaticPinvoke.ResumeThread(pOpenThread); //var suspendCount = 0; do { item.SuspendCnt = (uint)NativeMethods.ResumeThread(pOpenThread); } while (item.SuspendCnt > 0); NativeMethods.CloseHandle(pOpenThread); } }
static void SuspendAllThreads(SetupDesktop.CefProcess item) { Process cefProcess = new Process(); foreach (ProcessThread thread in cefProcess.Threads)//item.proc.Threads) { var pOpenThread = NativeMethods.OpenThread(NativeMethods.ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); if (pOpenThread == IntPtr.Zero) { break; // continue; } //StaticPinvoke.SuspendThread(pOpenThread); if (item.SuspendCnt == 0) { item.SuspendCnt = NativeMethods.SuspendThread(pOpenThread); } NativeMethods.CloseHandle(pOpenThread); } }