public static string dumpProcStats(ProcessStatsEventArgs procStats) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (KeyValuePair<string, process_statistics> ps in procStats.procStatistics) { sb.Append(ps.Value.sName + "\t"); sb.Append((ps.Value.procUsage.kernel + ps.Value.procUsage.user).ToString() + "\r\n"); } sb.Append("Duration:\t" + procStats.duration + "\r\n"); return sb.ToString(); }
public static string dumpProcStats(ProcessStatsEventArgs procStats) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (KeyValuePair <string, process_statistics> ps in procStats.procStatistics) { sb.Append(ps.Value.sName + "\t"); sb.Append((ps.Value.procUsage.kernel + ps.Value.procUsage.user).ToString() + "\r\n"); } sb.Append("Duration:\t" + procStats.duration + "\r\n"); return(sb.ToString()); }
void onUpdateHandler(ProcessStatsEventArgs procStats) { //anyone listening? if (this.updateEvent == null) return; this.updateEvent(this, procStats); }
void pInfo_updateEvent(object sender, ProcessStatsEventArgs eventArgs) { setText( ProcessStatistics.dumpProcStats(eventArgs)); addData(eventArgs); }
void addData (ProcessStatsEventArgs procStats) { if (this.dataGrid1.InvokeRequired) { addDataCallback d = new addDataCallback(addData); this.Invoke(d, new object[] { procStats }); } else { dataGrid1.SuspendLayout(); //dtProcesses.Rows.Clear(); foreach (KeyValuePair<string, ProcessStatistics.process_statistics> ps in procStats.procStatistics) { object[] o = new object[] { ps.Value.processID, ps.Value.sName, ps.Value.procUsage.user, ps.Value.procUsage.kernel, ps.Value.dateTime, ps.Value.duration }; DataRow dr; //check if data already exists dr = dsProcesses.Tables[0].Rows.Find(ps.Value.processID.ToString()); if (dr == null) { //add a new row dr = dtProcesses.NewRow(); dr.ItemArray = o; dtProcesses.Rows.Add(dr); } else dr.ItemArray = o; } dataGrid1.Refresh(); dataGrid1.ResumeLayout(); //object[] o = new object[7]{ procUsage.procStatistics. .procStatistics. [i].sApp, eventEntries[i].sArg, eventEntries[i].sEvent, // eventEntries[i].sStartTime, eventEntries[i].sEndTime, eventEntries[i].sType, eventEntries[i].sHandle }; } }