public Monitor Attach(uint id, Monitor.ExitHandler exitHandler) { if (!HDPlusModule.ManagerAttach(this.handle, id)) { CommonError.ThrowLastWin32Error("Cannot attach to monitor " + id.ToString()); } return(new Monitor(this.handle, id, exitHandler)); }
public Monitor(IntPtr handle, uint id, Monitor.ExitHandler exitHandler) { this.handle = handle; this.id = id; new Thread((ThreadStart)(() => { while (ProcessUtils.IsProcessAlive(Convert.ToInt32(id))) { Thread.Sleep(1000); } exitHandler(); })) { IsBackground = true }.Start(); }