public ProcessHandle(Process process, int customId = -1) { this.CustomId = customId; this.Process = process ?? throw new NullReferenceException(); process.Refresh(); if (process.Id == 0) { throw new Exception("Process does not appear to be running"); } ProcessHandleManager.RegisterHandle(this); }
/// <summary> /// Optional. If the specified process exits, the handle will be disposed of automatically /// </summary> public void Dispose() { ProcessHandleManager.UnregisterHandle(this); }