Added and fixed WorkItemsGroupDemoMono

Also fixed Performance Counter which doesn't work on Mono
This commit is contained in:
Ami Bar
2009-12-24 01:41:55 +02:00
parent 48de8aca66
commit d3ebec6a1b
9 changed files with 399 additions and 191 deletions
+93 -92
View File
@@ -64,8 +64,14 @@ namespace WorkItemsGroupDemo
this.comboWIPriority2 = new System.Windows.Forms.ComboBox();
this.comboWIPriority3 = new System.Windows.Forms.ComboBox();
this.btnMode = new System.Windows.Forms.Button();
this.queueUsageControl6 = new UsageControl.QueueUsageControl();
this.queueUsageControl2 = new UsageControl.QueueUsageControl();
this.queueUsageControl1 = new UsageControl.QueueUsageControl();
this.queueUsageControl3 = new UsageControl.QueueUsageControl();
this.usageHistorySTP = new UsageControl.UsageHistoryControl();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.usageThreadsInPool = new UsageControl.UsageControl();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
@@ -95,12 +101,6 @@ namespace WorkItemsGroupDemo
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.queueUsageControl6 = new UsageControl.QueueUsageControl();
this.queueUsageControl2 = new UsageControl.QueueUsageControl();
this.queueUsageControl1 = new UsageControl.QueueUsageControl();
this.queueUsageControl3 = new UsageControl.QueueUsageControl();
this.usageThreadsInPool = new UsageControl.UsageControl();
this.usageHistorySTP = new UsageControl.UsageHistoryControl();
((System.ComponentModel.ISupportInitialize)(this.spinCon6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spinCon1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spinCon3)).BeginInit();
@@ -643,6 +643,78 @@ namespace WorkItemsGroupDemo
this.btnMode.UseVisualStyleBackColor = true;
this.btnMode.Click += new System.EventHandler(this.btnMode_Click);
//
// queueUsageControl6
//
this.queueUsageControl6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.queueUsageControl6.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl6.Location = new System.Drawing.Point(39, 19);
this.queueUsageControl6.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl6.Name = "queueUsageControl6";
this.queueUsageControl6.Size = new System.Drawing.Size(72, 346);
this.queueUsageControl6.TabIndex = 30;
this.queueUsageControl6.TabStop = false;
this.toolTip1.SetToolTip(this.queueUsageControl6, "Smart Thread Pool Queue. The head of the queue is at the bottom. Executed work i" +
"tems are shown blinking.");
//
// queueUsageControl2
//
this.queueUsageControl2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl2.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl2.CausesValidation = false;
this.queueUsageControl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl2.Location = new System.Drawing.Point(102, 44);
this.queueUsageControl2.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl2.Name = "queueUsageControl2";
this.queueUsageControl2.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl2.TabIndex = 26;
this.toolTip1.SetToolTip(this.queueUsageControl2, "Work Items Group #2 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// queueUsageControl1
//
this.queueUsageControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl1.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl1.CausesValidation = false;
this.queueUsageControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl1.Location = new System.Drawing.Point(17, 44);
this.queueUsageControl1.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl1.Name = "queueUsageControl1";
this.queueUsageControl1.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl1.TabIndex = 25;
this.toolTip1.SetToolTip(this.queueUsageControl1, "Work Items Group #1 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// queueUsageControl3
//
this.queueUsageControl3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl3.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl3.CausesValidation = false;
this.queueUsageControl3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl3.Location = new System.Drawing.Point(186, 44);
this.queueUsageControl3.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl3.Name = "queueUsageControl3";
this.queueUsageControl3.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl3.TabIndex = 27;
this.toolTip1.SetToolTip(this.queueUsageControl3, "Work Items Group #3 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// usageHistorySTP
//
this.usageHistorySTP.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.usageHistorySTP.BackColor = System.Drawing.Color.Black;
this.usageHistorySTP.Location = new System.Drawing.Point(8, 16);
this.usageHistorySTP.Maximum = 100;
this.usageHistorySTP.Name = "usageHistorySTP";
this.usageHistorySTP.Size = new System.Drawing.Size(501, 104);
this.usageHistorySTP.TabIndex = 0;
this.toolTip1.SetToolTip(this.usageHistorySTP, "Smart Thread Pool usage. Green means used threads. Red means threads in pool.");
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -665,6 +737,20 @@ namespace WorkItemsGroupDemo
this.groupBox1.TabStop = false;
this.groupBox1.Text = "STP Usage";
//
// usageThreadsInPool
//
this.usageThreadsInPool.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.usageThreadsInPool.BackColor = System.Drawing.Color.Black;
this.usageThreadsInPool.Location = new System.Drawing.Point(25, 16);
this.usageThreadsInPool.Maximum = 20;
this.usageThreadsInPool.Name = "usageThreadsInPool";
this.usageThreadsInPool.Size = new System.Drawing.Size(41, 104);
this.usageThreadsInPool.TabIndex = 0;
this.usageThreadsInPool.Value1 = 0;
this.usageThreadsInPool.Value2 = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lblWaitingCallbacks);
@@ -755,6 +841,7 @@ namespace WorkItemsGroupDemo
this.groupWIGQueues.Controls.Add(this.lblStatus2);
this.groupWIGQueues.Controls.Add(this.lblStatus3);
this.groupWIGQueues.Dock = System.Windows.Forms.DockStyle.Left;
this.groupWIGQueues.Enabled = false;
this.groupWIGQueues.Location = new System.Drawing.Point(178, 3);
this.groupWIGQueues.Name = "groupWIGQueues";
this.groupWIGQueues.Size = new System.Drawing.Size(275, 391);
@@ -1020,92 +1107,6 @@ namespace WorkItemsGroupDemo
this.tableLayoutPanel1.Size = new System.Drawing.Size(615, 557);
this.tableLayoutPanel1.TabIndex = 95;
//
// queueUsageControl6
//
this.queueUsageControl6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.queueUsageControl6.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl6.Location = new System.Drawing.Point(39, 19);
this.queueUsageControl6.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl6.Name = "queueUsageControl6";
this.queueUsageControl6.Size = new System.Drawing.Size(72, 346);
this.queueUsageControl6.TabIndex = 30;
this.queueUsageControl6.TabStop = false;
this.toolTip1.SetToolTip(this.queueUsageControl6, "Smart Thread Pool Queue. The head of the queue is at the bottom. Executed work i" +
"tems are shown blinking.");
//
// queueUsageControl2
//
this.queueUsageControl2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl2.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl2.CausesValidation = false;
this.queueUsageControl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl2.Location = new System.Drawing.Point(102, 44);
this.queueUsageControl2.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl2.Name = "queueUsageControl2";
this.queueUsageControl2.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl2.TabIndex = 26;
this.toolTip1.SetToolTip(this.queueUsageControl2, "Work Items Group #2 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// queueUsageControl1
//
this.queueUsageControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl1.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl1.CausesValidation = false;
this.queueUsageControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl1.Location = new System.Drawing.Point(17, 44);
this.queueUsageControl1.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl1.Name = "queueUsageControl1";
this.queueUsageControl1.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl1.TabIndex = 25;
this.toolTip1.SetToolTip(this.queueUsageControl1, "Work Items Group #1 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// queueUsageControl3
//
this.queueUsageControl3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.queueUsageControl3.BackColor = System.Drawing.Color.Transparent;
this.queueUsageControl3.CausesValidation = false;
this.queueUsageControl3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.queueUsageControl3.Location = new System.Drawing.Point(186, 44);
this.queueUsageControl3.Margin = new System.Windows.Forms.Padding(6);
this.queueUsageControl3.Name = "queueUsageControl3";
this.queueUsageControl3.Size = new System.Drawing.Size(72, 321);
this.queueUsageControl3.TabIndex = 27;
this.toolTip1.SetToolTip(this.queueUsageControl3, "Work Items Group #3 Queue. Each Work Items Group has unique color for its work it" +
"ems.");
//
// usageThreadsInPool
//
this.usageThreadsInPool.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.usageThreadsInPool.BackColor = System.Drawing.Color.Black;
this.usageThreadsInPool.Location = new System.Drawing.Point(25, 16);
this.usageThreadsInPool.Maximum = 20;
this.usageThreadsInPool.Name = "usageThreadsInPool";
this.usageThreadsInPool.Size = new System.Drawing.Size(41, 104);
this.usageThreadsInPool.TabIndex = 0;
this.usageThreadsInPool.Value1 = 0;
this.usageThreadsInPool.Value2 = 0;
//
// usageHistorySTP
//
this.usageHistorySTP.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.usageHistorySTP.BackColor = System.Drawing.Color.Black;
this.usageHistorySTP.Location = new System.Drawing.Point(8, 16);
this.usageHistorySTP.Maximum = 100;
this.usageHistorySTP.Name = "usageHistorySTP";
this.usageHistorySTP.Size = new System.Drawing.Size(501, 104);
this.usageHistorySTP.TabIndex = 0;
this.toolTip1.SetToolTip(this.usageHistorySTP, "Smart Thread Pool usage. Green means used threads. Red means threads in pool.");
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+116 -31
View File
@@ -17,7 +17,7 @@ namespace WorkItemsGroupDemo
private bool _advancedMode = false;
private int _workItemsGenerated;
Hashtable _workingStates = Hashtable.Synchronized(new Hashtable());
private SmartThreadPool _stp;
private SmartThreadPool _smartThreadPool;
private IWorkItemsGroup _wig1;
private IWorkItemsGroup _wig2;
private IWorkItemsGroup _wig3;
@@ -43,6 +43,8 @@ namespace WorkItemsGroupDemo
private Func<long> _getQueuedWorkItems;
private Func<long> _getCompletedWorkItems;
private static bool _useWindowsPerformanceCounters;
private class WigEntry
{
public IWorkItemsGroup _wig;
@@ -80,20 +82,27 @@ namespace WorkItemsGroupDemo
{
StartSuspended = true,
MaxWorkerThreads = ((int)spinCon6.Value),
IdleTimeout = int.Parse(spinIdleTimeout.Text)*1000,
PerformanceCounterInstanceName = "SmartThreadPoolDemo",
EnableLocalPerformanceCounters = true,
IdleTimeout = int.Parse(spinIdleTimeout.Text) * 1000,
};
_stp = new SmartThreadPool(stpStartInfo);
_wig1 = _stp.CreateWorkItemsGroup((int)spinCon1.Value);
_wig2 = _stp.CreateWorkItemsGroup((int)spinCon2.Value);
_wig3 = _stp.CreateWorkItemsGroup((int)spinCon3.Value);
if (_useWindowsPerformanceCounters)
{
stpStartInfo.PerformanceCounterInstanceName = "WIG Test SmartThreadPool";
}
else
{
stpStartInfo.EnableLocalPerformanceCounters = true;
}
_smartThreadPool = new SmartThreadPool(stpStartInfo);
_wig1 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon1.Value);
_wig2 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon2.Value);
_wig3 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon3.Value);
spinCon1.Tag = _wig1;
spinCon2.Tag = _wig2;
spinCon3.Tag = _wig3;
spinCon6.Tag = _stp;
spinCon6.Tag = _smartThreadPool;
comboWIPriority1.SelectedIndex = 1;
comboWIPriority2.SelectedIndex = 1;
@@ -112,9 +121,85 @@ namespace WorkItemsGroupDemo
}
}
private void InitializeGUIPerformanceCounters()
public static void Init()
{
#if _WINDOWS
_useWindowsPerformanceCounters = InitializePerformanceCounters();
#endif
}
// This method is a work around for the Peformance Counter issue.
// When the first SmartThreadPool is created with a Peformance
// Counter name on a machine, it creates the SmartThreadPool
// Peformance Counter category. In this demo I am using the Performance
// Counters to update the GUI.
// The issue is that if this demo runs for the first time on the
// machine, it creates the Peformance Counter category and then
// uses it.
// I don't know why, but every time the demo runs for the first
// time on a machine, it fails to connect to the Peformance Counters,
// because it can't find the Peformance Counter category.
// The work around is to check if the category exists, and if not
// create a SmartThreadPool instance that will create the category.
// After that I spawn another process that runs the demo.
// I tried the another work around and thats to check for the category
// existance, run a second process that will create the category,
// and then continue with the first process, but it doesn't work.
// Thank you for reading the whole comment. If you have another way
// to solve this issue please contact me: amibar@gmail.com.
private static bool InitializePerformanceCounters()
{
if (!PerformanceCounterCategory.Exists("SmartThreadPool"))
{
STPStartInfo stpStartInfo = new STPStartInfo();
stpStartInfo.PerformanceCounterInstanceName = "WIG Test SmartThreadPool";
SmartThreadPool stp = new SmartThreadPool(stpStartInfo);
stp.Shutdown();
if (!PerformanceCounterCategory.Exists("SmartThreadPool"))
{
MessageBox.Show("Failed to create Performance Counters category.\r\nIf you run on Vista or Windows 7, you need to run for the first time as Administrator to create the performance counters category.\r\n\r\nUsing internal performance counters instead.", "Test Smart Thread Pool", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
Process process = new Process();
process.StartInfo.FileName = Application.ExecutablePath;
try
{
process.Start();
}
catch (Exception e)
{
e.GetHashCode();
MessageBox.Show("If this is the first time you get this message,\r\nplease try to run the demo again.", "Test Smart Thread Pool");
}
return false;
}
return true;
}
private void InitializeGUIPerformanceCounters()
{
if (_useWindowsPerformanceCounters)
{
InitializeWindowsPerformanceCounters();
}
else
{
InitializeLocalPerformanceCounters();
}
}
partial void InitializeWindowsPerformanceCounters();
#if _WINDOWS
partial void InitializeWindowsPerformanceCounters()
{
this._pcActiveThreads = new System.Diagnostics.PerformanceCounter();
this._pcInUseThreads = new System.Diagnostics.PerformanceCounter();
this._pcQueuedWorkItems = new System.Diagnostics.PerformanceCounter();
@@ -125,40 +210,40 @@ namespace WorkItemsGroupDemo
//
this._pcActiveThreads.CategoryName = "SmartThreadPool";
this._pcActiveThreads.CounterName = "Active threads";
this._pcActiveThreads.InstanceName = "SmartThreadPoolDemo";
this._pcActiveThreads.InstanceName = "Test SmartThreadPool";
//
// pcInUseThreads
//
this._pcInUseThreads.CategoryName = "SmartThreadPool";
this._pcInUseThreads.CounterName = "In use threads";
this._pcInUseThreads.InstanceName = "SmartThreadPoolDemo";
this._pcInUseThreads.InstanceName = "Test SmartThreadPool";
//
// pcQueuedWorkItems
//
this._pcQueuedWorkItems.CategoryName = "SmartThreadPool";
this._pcQueuedWorkItems.CounterName = "Work Items in queue";
this._pcQueuedWorkItems.InstanceName = "SmartThreadPoolDemo";
this._pcQueuedWorkItems.InstanceName = "Test SmartThreadPool";
//
// pcCompletedWorkItems
//
this._pcCompletedWorkItems.CategoryName = "SmartThreadPool";
this._pcCompletedWorkItems.CounterName = "Work Items processed";
this._pcCompletedWorkItems.InstanceName = "SmartThreadPoolDemo";
this._pcCompletedWorkItems.InstanceName = "Test SmartThreadPool";
_getActiveThreads = () => (long)_pcActiveThreads.NextValue();
_getInUseThreads = () => (long)_pcInUseThreads.NextValue();
_getQueuedWorkItems = () => (long)_pcQueuedWorkItems.NextValue();
_getCompletedWorkItems = () => (long)_pcCompletedWorkItems.NextValue();
#else
_getActiveThreads = delegate () { return _stp.PerformanceCountersReader.ActiveThreads; };
_getInUseThreads = delegate () { return _stp.PerformanceCountersReader.InUseThreads; };
_getQueuedWorkItems = delegate () { return _stp.PerformanceCountersReader.WorkItemsQueued; };
_getCompletedWorkItems = delegate () { return _stp.PerformanceCountersReader.WorkItemsProcessed; };
#endif
}
#endif
private void InitializeLocalPerformanceCounters()
{
_getActiveThreads = () => _smartThreadPool.PerformanceCountersReader.ActiveThreads;
_getInUseThreads = () => _smartThreadPool.PerformanceCountersReader.InUseThreads;
_getQueuedWorkItems = () => _smartThreadPool.PerformanceCountersReader.WorkItemsQueued;
_getCompletedWorkItems = () => _smartThreadPool.PerformanceCountersReader.WorkItemsProcessed;
}
private void btnStart_Click(object sender, EventArgs e)
{
@@ -179,7 +264,7 @@ namespace WorkItemsGroupDemo
{
_workItemsGenerated = 0;
UpdateControls(true);
_stp.Start();
_smartThreadPool.Start();
_wig1.Start();
_wig2.Start();
_wig3.Start();
@@ -187,7 +272,7 @@ namespace WorkItemsGroupDemo
private void Shutdown()
{
_stp.Shutdown(false, 2000);
_smartThreadPool.Shutdown(false, 2000);
InitSTP();
UpdateControls(false);
}
@@ -244,7 +329,7 @@ namespace WorkItemsGroupDemo
private void UpdateWorkingSet()
{
lblStatus6.Text = _stp.IsIdle ? "Idle" : "Working";
lblStatus6.Text = _smartThreadPool.IsIdle ? "Idle" : "Working";
object [] statesWorking = null;
lock (_workingStates.SyncRoot)
@@ -253,7 +338,7 @@ namespace WorkItemsGroupDemo
_workingStates.Keys.CopyTo(statesWorking, 0);
}
object[] statesSTP = _stp.GetStates();
object[] statesSTP = _smartThreadPool.GetStates();
List<QueueUsageControl.QueueUsageEntry> list = new List<QueueUsageControl.QueueUsageEntry>();
@@ -373,7 +458,7 @@ namespace WorkItemsGroupDemo
private void btnCancel6_Click(object sender, EventArgs e)
{
_stp.Cancel();
_smartThreadPool.Cancel();
}
private void spinCon_ValueChanged(object sender, EventArgs e)
@@ -388,7 +473,7 @@ namespace WorkItemsGroupDemo
EnqueueWorkItems(ref _lastIndex[0], Convert.ToInt32(spinProduction1.Value), "#", _wig1Color, (WorkItemPriority)(2 * comboWIPriority1.SelectedIndex), _wig1, Convert.ToInt32(spinDuration1.Value));
EnqueueWorkItems(ref _lastIndex[1], Convert.ToInt32(spinProduction2.Value), "#", _wig2Color, (WorkItemPriority)(2 * comboWIPriority2.SelectedIndex), _wig2, Convert.ToInt32(spinDuration2.Value));
EnqueueWorkItems(ref _lastIndex[2], Convert.ToInt32(spinProduction3.Value), "#", _wig3Color, (WorkItemPriority)(2 * comboWIPriority3.SelectedIndex), _wig3, Convert.ToInt32(spinDuration3.Value));
EnqueueWorkItems(ref _lastIndex[3], Convert.ToInt32(spinProduction6.Value), "#", _stpColor, (WorkItemPriority)(2 * comboWIPriority6.SelectedIndex), _stp, Convert.ToInt32(spinDuration6.Value));
EnqueueWorkItems(ref _lastIndex[3], Convert.ToInt32(spinProduction6.Value), "#", _stpColor, (WorkItemPriority)(2 * comboWIPriority6.SelectedIndex), _smartThreadPool, Convert.ToInt32(spinDuration6.Value));
}
private void btnMode_Click(object sender, EventArgs e)
@@ -400,13 +485,13 @@ namespace WorkItemsGroupDemo
private void UpdateModeControls()
{
btnMode.Text = _advancedMode ? "Basic <<" : "Advanced >>";
panelWIGsCtrls.Visible = _advancedMode;
groupWIGQueues.Visible = _advancedMode;
panelWIGsCtrls.Enabled = _advancedMode;
groupWIGQueues.Enabled = _advancedMode;
}
private void timerPoll_Tick(object sender, EventArgs e)
{
SmartThreadPool stp = _stp;
SmartThreadPool stp = _smartThreadPool;
if (null == stp)
{
return;
-15
View File
@@ -123,24 +123,9 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 7</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>94, 4</value>
</metadata>
<metadata name="timer2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>186, 4</value>
</metadata>
<metadata name="pcActiveThreads.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="pcInUseThreads.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>150, 54</value>
</metadata>
<metadata name="pcQueuedWorkItems.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>282, 54</value>
</metadata>
<metadata name="pcCompletedWorkItems.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>438, 54</value>
</metadata>
<metadata name="timerPoll.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>609, 54</value>
</metadata>
+2
View File
@@ -11,6 +11,8 @@ namespace WorkItemsGroupDemo
[STAThread]
public static void Main()
{
Form1.Init();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
@@ -0,0 +1,96 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4B1DED71-6B32-4D9A-A811-120E5F1187D9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WorkItemsGroupDemo</RootNamespace>
<AssemblyName>WorkItemsGroupDemoMono</AssemblyName>
<StartupObject>WorkItemsGroupDemo.Program</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;_MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;_MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<SubType>Designer</SubType>
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmartThreadPool\SmartThreadPool.csproj">
<Project>{74D4C33F-7CC8-4B2A-A7DF-D8B6E63B6EBD}</Project>
<Name>SmartThreadPool</Name>
</ProjectReference>
<ProjectReference Include="..\UsageControl\UsageControl.csproj">
<Project>{C11A4561-CCB5-4C96-8DF2-B804031D89D8}</Project>
<Name>UsageControl</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>