private ProcessThreadTimes GetProcessTimes()
{
SafeProcessHandle handle = null;
try
{
handle = GetProcessHandle(Interop.Advapi32.ProcessOptions.PROCESS_QUERY_LIMITED_INFORMATION, false);
if (handle.IsInvalid)
{
throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString(CultureInfo.CurrentCulture)));
}
ProcessThreadTimes processTimes = new ProcessThreadTimes();
if (!Interop.Kernel32.GetProcessTimes(handle,
out processTimes._create, out processTimes._exit,
out processTimes._kernel, out processTimes._user))
{
throw new Win32Exception();
}
return processTimes;
}
finally
{
ReleaseProcessHandle(handle);
}
}