Modifica stats x threads
This commit is contained in:
@@ -148,5 +148,6 @@
|
||||
<thread name="userSK" value="250" />
|
||||
<thread name="warmers" value="500" />
|
||||
<thread name="watchdog" value="250" />
|
||||
<thread name="stats" value="2000" />
|
||||
</sampling>
|
||||
</serverConfig>
|
||||
@@ -230,21 +230,35 @@ public static class ThreadsFunctions
|
||||
|
||||
internal static void StatThread()
|
||||
{
|
||||
int samplePeriod = samplMsec("stats") > 0 ? samplMsec("stats") : 1000;
|
||||
|
||||
while (true)
|
||||
{
|
||||
long totTime = 0;
|
||||
foreach (var value in Counter)
|
||||
{
|
||||
if (ThreadsHandler.RunningThreadStatus.ContainsKey(value.Key) && Counter[value.Key] != 0)
|
||||
{
|
||||
ThreadsHandler.RunningThreadStatus[value.Key] = $"{(Timers[value.Key] / Counter[value.Key])} ms x {Counter[value.Key]}";
|
||||
totTime += Timers[value.Key];
|
||||
ThreadsHandler.RunningThreadStatus[value.Key] = $"{((double)Timers[value.Key] / samplePeriod):P1} | {(Timers[value.Key] / Counter[value.Key])} ms x {Counter[value.Key]}";
|
||||
Timers[value.Key] = 0;
|
||||
Counter[value.Key] = 0;
|
||||
}
|
||||
}
|
||||
// aggiungo totale
|
||||
string grandTotal = $"{((double)totTime / samplePeriod):P1} | {totTime} ms";
|
||||
if (ThreadsHandler.RunningThreadStatus.ContainsKey(" TOTAL"))
|
||||
{
|
||||
ThreadsHandler.RunningThreadStatus[" TOTAL"] = grandTotal;
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadsHandler.RunningThreadStatus.Add(" TOTAL", grandTotal);
|
||||
}
|
||||
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
|
||||
|
||||
Thread.Sleep(2000);
|
||||
Thread.Sleep(samplePeriod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -172,7 +172,7 @@ namespace Thermo.Active.UI
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.TXTstatus, 2);
|
||||
this.TXTstatus.Enabled = false;
|
||||
this.TXTstatus.Location = new System.Drawing.Point(3, 435);
|
||||
this.TXTstatus.Location = new System.Drawing.Point(3, 620);
|
||||
this.TXTstatus.Name = "TXTstatus";
|
||||
this.TXTstatus.ReadOnly = true;
|
||||
this.TXTstatus.Size = new System.Drawing.Size(438, 20);
|
||||
@@ -200,7 +200,7 @@ namespace Thermo.Active.UI
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 54F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(444, 457);
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(444, 642);
|
||||
this.tableLayoutPanel1.TabIndex = 58;
|
||||
//
|
||||
// stopServerButton
|
||||
@@ -209,7 +209,7 @@ namespace Thermo.Active.UI
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.stopServerButton.Location = new System.Drawing.Point(225, 381);
|
||||
this.stopServerButton.Location = new System.Drawing.Point(225, 566);
|
||||
this.stopServerButton.Name = "stopServerButton";
|
||||
this.stopServerButton.Size = new System.Drawing.Size(216, 48);
|
||||
this.stopServerButton.TabIndex = 3;
|
||||
@@ -223,7 +223,7 @@ namespace Thermo.Active.UI
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.openUiButton.Location = new System.Drawing.Point(3, 381);
|
||||
this.openUiButton.Location = new System.Drawing.Point(3, 566);
|
||||
this.openUiButton.Name = "openUiButton";
|
||||
this.openUiButton.Size = new System.Drawing.Size(216, 48);
|
||||
this.openUiButton.TabIndex = 58;
|
||||
@@ -244,7 +244,7 @@ namespace Thermo.Active.UI
|
||||
this.panel1.Controls.Add(this.CHNcConnected);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.TXTMachId);
|
||||
this.panel1.Location = new System.Drawing.Point(3, 292);
|
||||
this.panel1.Location = new System.Drawing.Point(3, 477);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(438, 83);
|
||||
this.panel1.TabIndex = 9;
|
||||
@@ -326,7 +326,7 @@ namespace Thermo.Active.UI
|
||||
this.LISTThreadStatus.HideSelection = false;
|
||||
this.LISTThreadStatus.Location = new System.Drawing.Point(3, 3);
|
||||
this.LISTThreadStatus.Name = "LISTThreadStatus";
|
||||
this.LISTThreadStatus.Size = new System.Drawing.Size(438, 283);
|
||||
this.LISTThreadStatus.Size = new System.Drawing.Size(438, 468);
|
||||
this.LISTThreadStatus.TabIndex = 59;
|
||||
this.LISTThreadStatus.UseCompatibleStateImageBehavior = false;
|
||||
this.LISTThreadStatus.View = System.Windows.Forms.View.Details;
|
||||
@@ -334,12 +334,12 @@ namespace Thermo.Active.UI
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Thread Name";
|
||||
this.columnHeader1.Width = 328;
|
||||
this.columnHeader1.Width = 200;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Time";
|
||||
this.columnHeader2.Width = 78;
|
||||
this.columnHeader2.Width = 230;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
@@ -437,7 +437,7 @@ namespace Thermo.Active.UI
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(468, 496);
|
||||
this.ClientSize = new System.Drawing.Size(468, 681);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
|
||||
@@ -267,14 +267,16 @@ namespace Thermo.Active.UI
|
||||
if (!isUpdatingThreads)
|
||||
{
|
||||
isUpdatingThreads = true;
|
||||
Dictionary<String, String> Threads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
Dictionary<String, String> myThreads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
//Begin the update
|
||||
LISTThreadStatus.BeginUpdate();
|
||||
//clear the List
|
||||
LISTThreadStatus.Items.Clear();
|
||||
//Add all items
|
||||
foreach (KeyValuePair<string, String> Thr in Threads)
|
||||
foreach (KeyValuePair<string, String> Thr in myThreads)
|
||||
{
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new String[]{Thr.Key,Thr.Value }));
|
||||
}
|
||||
//End the update
|
||||
LISTThreadStatus.EndUpdate();
|
||||
isUpdatingThreads = false;
|
||||
|
||||
Reference in New Issue
Block a user