publicclassProcess : Component { public IntPtr MainWindowHandle { [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { if (!haveMainWindow) { EnsureState(State.IsLocal | State.HaveId); mainWindowHandle = ProcessManager.GetMainWindowHandle(processId); if (mainWindowHandle != (IntPtr)0) { haveMainWindow = true; } else { // We do the following only for the side-effect that it will throw when if the process no longer exists on the system. In Whidbey // we always did this check but have now changed it to just require a ProcessId. In the case where someone has called Refresh() // and the process has exited this call will throw an exception where as the above code would return 0 as the handle. EnsureState(State.HaveProcessInfo); } } return mainWindowHandle; } } }