System.Diagnostics.Process.GetProcessTimes C# (CSharp) Method

GetProcessTimes() private method

Gets timing information for the current process.
private GetProcessTimes ( ) : System.Diagnostics.ProcessThreadTimes
return System.Diagnostics.ProcessThreadTimes
        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);
            }
        }