-
Notifications
You must be signed in to change notification settings - Fork 1
/
UnityProcessStatus.cs
44 lines (42 loc) · 1.71 KB
/
UnityProcessStatus.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// System libraries
using System;
using System.Diagnostics;
namespace devunity.components
{
public class UnityProcessStatus
{
// Main function
public static void ProcessStatus()
{
Console.Write("Process to get status of: ");
string pName = Console.ReadLine();
Console.WriteLine();
if (pName.Contains("unity"))
{
try
{
Process[] pArray = Process.GetProcessesByName(pName);
foreach (Process p in pArray)
{
Console.WriteLine($"{pName}:");
Console.WriteLine($" Process ID : {p.Id}");
Console.WriteLine($" Physical memory usage : {p.WorkingSet64}");
Console.WriteLine($" User processor time : {p.UserProcessorTime}");
Console.WriteLine($" Privileged processor time : {p.PrivilegedProcessorTime}");
Console.WriteLine($" Total processor time : {p.TotalProcessorTime}");
Console.WriteLine(" -----------------------------------------------------");
Console.WriteLine();
}
} catch {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("ERROR: NO SUCH PROCESS");
Environment.Exit(127);
}
} else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("ERROR: NOT A UNITY PROCESS");
Environment.Exit(-1);
}
}
}
}