mirror of https://github.com/quasar/Quasar.git
Merge pull request #137 from MaxXor/revert-136-CpuRamUsage
Revert "CPU/RAM usage of each process"
This commit is contained in:
commit
8122b76c02
|
@ -292,10 +292,6 @@ namespace xClient.Core.Commands
|
|||
string[] processes = new string[pList.Length];
|
||||
int[] ids = new int[pList.Length];
|
||||
string[] titles = new string[pList.Length];
|
||||
decimal[] cpuUsage = new decimal[pList.Length];
|
||||
long[] memoryUsage = new long[pList.Length];
|
||||
|
||||
decimal TotalCpuUsage = GetTotalCpuUsage();
|
||||
|
||||
int i = 0;
|
||||
foreach (Process p in pList)
|
||||
|
@ -303,77 +299,12 @@ namespace xClient.Core.Commands
|
|||
processes[i] = p.ProcessName + ".exe";
|
||||
ids[i] = p.Id;
|
||||
titles[i] = p.MainWindowTitle;
|
||||
cpuUsage[i] = ((GetCpuUsage(p) / TotalCpuUsage) * 100);
|
||||
i++;
|
||||
}
|
||||
|
||||
new Packets.ClientPackets.GetProcessesResponse(processes, ids, titles).Execute(client);
|
||||
}
|
||||
|
||||
private static decimal GetTotalCpuUsage()
|
||||
{
|
||||
try
|
||||
{
|
||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
||||
{
|
||||
CategoryName = "Processor",
|
||||
CounterName = "% Processor Time",
|
||||
InstanceName = "_Total"
|
||||
};
|
||||
|
||||
CpuCounter.NextValue();
|
||||
Thread.Sleep(200);
|
||||
|
||||
return (decimal)CpuCounter.NextValue();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (decimal)100;
|
||||
}
|
||||
}
|
||||
|
||||
private static decimal GetCpuUsage(Process proc)
|
||||
{
|
||||
try
|
||||
{
|
||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
||||
{
|
||||
CategoryName = "Processor",
|
||||
CounterName = "% Processor Time",
|
||||
InstanceName = proc.ProcessName
|
||||
};
|
||||
|
||||
CpuCounter.NextValue();
|
||||
|
||||
return (decimal)CpuCounter.NextValue();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (decimal)0;
|
||||
}
|
||||
}
|
||||
|
||||
private static long GetMemoryUsage(Process proc)
|
||||
{
|
||||
try
|
||||
{
|
||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
||||
{
|
||||
CategoryName = "Memory",
|
||||
CounterName = "Available MBytes",
|
||||
InstanceName = proc.ProcessName
|
||||
};
|
||||
|
||||
CpuCounter.NextValue();
|
||||
|
||||
return (long)CpuCounter.NextValue();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (long)0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void HandleKillProcess(Packets.ServerPackets.KillProcess command, Client client)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -14,12 +14,6 @@ namespace xClient.Core.Packets.ClientPackets
|
|||
[ProtoMember(3)]
|
||||
public string[] Titles { get; set; }
|
||||
|
||||
[ProtoMember(4)]
|
||||
public decimal[] CpuUsage { get; set; }
|
||||
|
||||
[ProtoMember(5)]
|
||||
public long[] MemoryUsage { get; set; }
|
||||
|
||||
public GetProcessesResponse()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -207,8 +207,7 @@ namespace xServer.Core.Commands
|
|||
{
|
||||
ListViewItem lvi =
|
||||
new ListViewItem(new string[]
|
||||
{packet.Processes[i], packet.IDs[i].ToString(), packet.Titles[i],
|
||||
string.Format("{0:0%}", packet.CpuUsage[i]), string.Format("{0:0%}", packet.MemoryUsage[i])});
|
||||
{packet.Processes[i], packet.IDs[i].ToString(), packet.Titles[i]});
|
||||
try
|
||||
{
|
||||
client.Value.FrmTm.Invoke(
|
||||
|
|
|
@ -14,12 +14,6 @@ namespace xServer.Core.Packets.ClientPackets
|
|||
[ProtoMember(3)]
|
||||
public string[] Titles { get; set; }
|
||||
|
||||
[ProtoMember(4)]
|
||||
public decimal[] CpuUsage { get; set; }
|
||||
|
||||
[ProtoMember(5)]
|
||||
public long[] MemoryUsage { get; set; }
|
||||
|
||||
public GetProcessesResponse()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,14 +35,12 @@ namespace xServer.Forms
|
|||
this.ctxtMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.ctxtKillProcess = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctxtStartProcess = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctxtLine = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.ctxtRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.lstTasks = new xServer.Controls.ListViewEx();
|
||||
this.lstTasks = new ListViewEx();
|
||||
this.hProcessname = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.hPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.hTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.hCpu = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.hRam = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.ctxtLine = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.ctxtMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -54,13 +52,13 @@ namespace xServer.Forms
|
|||
this.ctxtLine,
|
||||
this.ctxtRefresh});
|
||||
this.ctxtMenu.Name = "ctxtMenu";
|
||||
this.ctxtMenu.Size = new System.Drawing.Size(142, 76);
|
||||
this.ctxtMenu.Size = new System.Drawing.Size(153, 98);
|
||||
//
|
||||
// ctxtKillProcess
|
||||
//
|
||||
this.ctxtKillProcess.Image = global::xServer.Properties.Resources.cancel;
|
||||
this.ctxtKillProcess.Name = "ctxtKillProcess";
|
||||
this.ctxtKillProcess.Size = new System.Drawing.Size(141, 22);
|
||||
this.ctxtKillProcess.Size = new System.Drawing.Size(152, 22);
|
||||
this.ctxtKillProcess.Text = "Kill Process";
|
||||
this.ctxtKillProcess.Click += new System.EventHandler(this.ctxtKillProcess_Click);
|
||||
//
|
||||
|
@ -68,20 +66,15 @@ namespace xServer.Forms
|
|||
//
|
||||
this.ctxtStartProcess.Image = global::xServer.Properties.Resources.run;
|
||||
this.ctxtStartProcess.Name = "ctxtStartProcess";
|
||||
this.ctxtStartProcess.Size = new System.Drawing.Size(141, 22);
|
||||
this.ctxtStartProcess.Size = new System.Drawing.Size(152, 22);
|
||||
this.ctxtStartProcess.Text = "Start Process";
|
||||
this.ctxtStartProcess.Click += new System.EventHandler(this.ctxtStartProcess_Click);
|
||||
//
|
||||
// ctxtLine
|
||||
//
|
||||
this.ctxtLine.Name = "ctxtLine";
|
||||
this.ctxtLine.Size = new System.Drawing.Size(138, 6);
|
||||
//
|
||||
// ctxtRefresh
|
||||
//
|
||||
this.ctxtRefresh.Image = global::xServer.Properties.Resources.refresh;
|
||||
this.ctxtRefresh.Name = "ctxtRefresh";
|
||||
this.ctxtRefresh.Size = new System.Drawing.Size(141, 22);
|
||||
this.ctxtRefresh.Size = new System.Drawing.Size(152, 22);
|
||||
this.ctxtRefresh.Text = "Refresh";
|
||||
this.ctxtRefresh.Click += new System.EventHandler(this.ctxtRefresh_Click);
|
||||
//
|
||||
|
@ -90,16 +83,14 @@ namespace xServer.Forms
|
|||
this.lstTasks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.hProcessname,
|
||||
this.hPID,
|
||||
this.hTitle,
|
||||
this.hCpu,
|
||||
this.hRam});
|
||||
this.hTitle});
|
||||
this.lstTasks.ContextMenuStrip = this.ctxtMenu;
|
||||
this.lstTasks.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lstTasks.FullRowSelect = true;
|
||||
this.lstTasks.GridLines = true;
|
||||
this.lstTasks.Location = new System.Drawing.Point(0, 0);
|
||||
this.lstTasks.Name = "lstTasks";
|
||||
this.lstTasks.Size = new System.Drawing.Size(442, 411);
|
||||
this.lstTasks.Size = new System.Drawing.Size(335, 411);
|
||||
this.lstTasks.TabIndex = 1;
|
||||
this.lstTasks.UseCompatibleStateImageBehavior = false;
|
||||
this.lstTasks.View = System.Windows.Forms.View.Details;
|
||||
|
@ -119,25 +110,22 @@ namespace xServer.Forms
|
|||
this.hTitle.Text = "Title";
|
||||
this.hTitle.Width = 115;
|
||||
//
|
||||
// hCpu
|
||||
// ctxtLine
|
||||
//
|
||||
this.hCpu.Text = "CPU";
|
||||
this.ctxtLine.Name = "ctxtLine";
|
||||
this.ctxtLine.Size = new System.Drawing.Size(149, 6);
|
||||
//
|
||||
// hRam
|
||||
//
|
||||
this.hRam.Text = "Memory";
|
||||
//
|
||||
// FrmTaskManager
|
||||
// frmTaskManager
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(442, 411);
|
||||
this.ClientSize = new System.Drawing.Size(335, 411);
|
||||
this.Controls.Add(this.lstTasks);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(458, 449);
|
||||
this.Name = "FrmTaskManager";
|
||||
this.MinimumSize = new System.Drawing.Size(351, 449);
|
||||
this.Name = "frmTaskManager";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "xRAT 2.0 - Task Manager []";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTaskManager_FormClosing);
|
||||
|
@ -158,7 +146,5 @@ namespace xServer.Forms
|
|||
private System.Windows.Forms.ColumnHeader hPID;
|
||||
private System.Windows.Forms.ColumnHeader hTitle;
|
||||
private System.Windows.Forms.ToolStripSeparator ctxtLine;
|
||||
private System.Windows.Forms.ColumnHeader hCpu;
|
||||
private System.Windows.Forms.ColumnHeader hRam;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue