Skip to content

Commit

Permalink
Changes as per PR Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
avodovnik committed Nov 23, 2020
1 parent 6c65eb7 commit 7857375
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1343,15 +1343,30 @@ private void StopWatchingForExit()

public override string ToString()
{
if (Associated && !HasExited)
string result = base.ToString();

try
{
string processName = ProcessName;
if (processName.Length != 0)
if (Associated)
{
return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", base.ToString(), processName);
_processInfo ??= ProcessManager.GetProcessInfo(_processId, _machineName);
if (_processInfo is not null)
{
string processName = _processInfo.ProcessName;
if (processName.Length != 0)
{
result = $"{result} ({processName})";
}
}
}
}
return base.ToString();
catch
{
// Handle cases where a process would exit straight after our checks
// and/or make ProcessManager throw an exception.
}

return result;
}

/// <devdoc>
Expand Down

0 comments on commit 7857375

Please sign in to comment.