mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-202377: Removed last instance of the QueuedBackgroundWorker and deleted the class.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
78ecef617d
commit
f4d92da5ee
@ -42,7 +42,6 @@ using XenAdmin.Core;
|
|||||||
using XenAdmin.Network;
|
using XenAdmin.Network;
|
||||||
using XenAdmin.Properties;
|
using XenAdmin.Properties;
|
||||||
using XenAPI;
|
using XenAPI;
|
||||||
using XenCenterLib;
|
|
||||||
|
|
||||||
|
|
||||||
namespace XenAdmin.Wizards.HAWizard_Pages
|
namespace XenAdmin.Wizards.HAWizard_Pages
|
||||||
@ -53,7 +52,7 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
private IXenConnection connection;
|
private IXenConnection connection;
|
||||||
|
|
||||||
private readonly CollectionChangeEventHandler VM_CollectionChangedWithInvoke;
|
private readonly CollectionChangeEventHandler VM_CollectionChangedWithInvoke;
|
||||||
private readonly QueuedBackgroundWorker m_worker;
|
private readonly List<VM> _vmsQueuedForUpdate = new List<VM>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// May not be set to null.
|
/// May not be set to null.
|
||||||
@ -160,8 +159,6 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
|
|
||||||
nudStartDelay.Maximum = long.MaxValue;
|
nudStartDelay.Maximum = long.MaxValue;
|
||||||
nudOrder.Maximum = long.MaxValue;
|
nudOrder.Maximum = long.MaxValue;
|
||||||
|
|
||||||
m_worker = new QueuedBackgroundWorker();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -256,7 +253,7 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
|
|
||||||
dataGridViewVms.Rows.AddRange(newRows.ToArray());
|
dataGridViewVms.Rows.AddRange(newRows.ToArray());
|
||||||
var addedVms = from row in dataGridViewVms.Rows.Cast<VmWithSettingsRow>() select row.Vm;
|
var addedVms = from row in dataGridViewVms.Rows.Cast<VmWithSettingsRow>() select row.Vm;
|
||||||
UpdateVMsAgility(addedVms);
|
UpdateVMsAgility(addedVms.ToList());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -267,17 +264,26 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts a new background thread that updates the displayed agility status for each VM.
|
/// Starts a new background thread that updates the displayed agility status for each VM.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateVMsAgility(IEnumerable<VM> vms)
|
private void UpdateVMsAgility(List<VM> vms)
|
||||||
{
|
{
|
||||||
Debug.Assert(connection != null, "Connection property must have been set to non-null before calling this function");
|
if (bgWorker.IsBusy)
|
||||||
|
{
|
||||||
//worker starts on UI (main) thread
|
foreach (var vm in vms)
|
||||||
m_worker.RunWorkerAsync((sender, arg) => worker_DoWork(null, vms), worker_RunWorkerCompleted);
|
{
|
||||||
|
if (!_vmsQueuedForUpdate.Contains(vm))
|
||||||
|
_vmsQueuedForUpdate.Add(vm);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private object worker_DoWork(object sender, object arg)
|
Debug.Assert(connection != null, "Connection is null; set it to non-null before calling this method.");
|
||||||
|
if (vms.Count > 0)
|
||||||
|
bgWorker.RunWorkerAsync(vms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
var vms = arg as IEnumerable<VM>;
|
var vms = e.Argument as IEnumerable<VM>;
|
||||||
Debug.Assert(vms != null);
|
Debug.Assert(vms != null);
|
||||||
|
|
||||||
Session session = connection.DuplicateSession();
|
Session session = connection.DuplicateSession();
|
||||||
@ -296,10 +302,10 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
e.Result = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Error != null)
|
if (e.Error != null)
|
||||||
{
|
{
|
||||||
@ -346,6 +352,13 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
row.FriendlyNonAgileReason = nonAgileReason;
|
row.FriendlyNonAgileReason = nonAgileReason;
|
||||||
}
|
}
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
||||||
|
if (_vmsQueuedForUpdate.Count > 0)
|
||||||
|
{
|
||||||
|
var vms = new List<VM>(_vmsQueuedForUpdate);
|
||||||
|
_vmsQueuedForUpdate.Clear();
|
||||||
|
UpdateVMsAgility(vms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsHaActivatedFirstTime(IEnumerable<VM> vms)
|
private bool IsHaActivatedFirstTime(IEnumerable<VM> vms)
|
||||||
@ -517,12 +530,12 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
|
|
||||||
private void m_dropDownButtonRestartPriority_Click(object sender, EventArgs e)
|
private void m_dropDownButtonRestartPriority_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var selectedRows = dataGridViewVms.SelectedRows.Cast<VmWithSettingsRow>();
|
var selectedRows = dataGridViewVms.SelectedRows.Cast<VmWithSettingsRow>().ToList();
|
||||||
|
|
||||||
foreach (ToolStripMenuItem item in contextMenuStrip.Items)
|
foreach (ToolStripMenuItem item in contextMenuStrip.Items)
|
||||||
{
|
{
|
||||||
var itemRestartPriority = ((VM.HA_Restart_Priority)item.Tag);
|
var itemRestartPriority = ((VM.HA_Restart_Priority)item.Tag);
|
||||||
item.Checked = selectedRows.Count() > 0 && selectedRows.All(s => s.RestartPriority == itemRestartPriority);
|
item.Checked = selectedRows.Count > 0 && selectedRows.All(s => s.RestartPriority == itemRestartPriority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +543,7 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
{
|
{
|
||||||
Program.AssertOnEventThread();
|
Program.AssertOnEventThread();
|
||||||
|
|
||||||
var selectedRows = dataGridViewVms.SelectedRows.Cast<VmWithSettingsRow>();
|
var selectedRows = dataGridViewVms.SelectedRows.Cast<VmWithSettingsRow>().ToList();
|
||||||
|
|
||||||
if (dataGridViewVms.SelectedRows.Count == 0)
|
if (dataGridViewVms.SelectedRows.Count == 0)
|
||||||
{
|
{
|
||||||
@ -578,11 +591,11 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
// set the order and delay NUDs
|
// set the order and delay NUDs
|
||||||
nudOrder.Enabled = nudStartDelay.Enabled = true;
|
nudOrder.Enabled = nudStartDelay.Enabled = true;
|
||||||
|
|
||||||
var orderDistList = (from row in selectedRows select row.StartOrder).Distinct();
|
var orderDistList = (from row in selectedRows select row.StartOrder).Distinct().ToList();
|
||||||
nudOrder.Text = orderDistList.Count() == 1 ? orderDistList.ElementAt(0).ToString() : "";
|
nudOrder.Text = orderDistList.Count == 1 ? orderDistList.ElementAt(0).ToString() : "";
|
||||||
|
|
||||||
var delayDistList = (from row in selectedRows select row.StartDelay).Distinct();
|
var delayDistList = (from row in selectedRows select row.StartDelay).Distinct().ToList();
|
||||||
nudStartDelay.Text = delayDistList.Count() == 1 ? delayDistList.ElementAt(0).ToString() : "";
|
nudStartDelay.Text = delayDistList.Count == 1 ? delayDistList.ElementAt(0).ToString() : "";
|
||||||
|
|
||||||
// check that all the VMs selected in the list are agile and make sure the protect button is disabled with the relevant reason
|
// check that all the VMs selected in the list are agile and make sure the protect button is disabled with the relevant reason
|
||||||
VmWithSettingsRow nonAgileRow = selectedRows.FirstOrDefault(r => !r.IsAgile);
|
VmWithSettingsRow nonAgileRow = selectedRows.FirstOrDefault(r => !r.IsAgile);
|
||||||
|
@ -39,6 +39,7 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
this.colDelay = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.colDelay = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.colAgile = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.colAgile = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.bgWorker = new System.ComponentModel.BackgroundWorker();
|
||||||
this.tableLayoutPanel1.SuspendLayout();
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStatus)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStatus)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudOrder)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nudOrder)).BeginInit();
|
||||||
@ -155,8 +156,8 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
resources.ApplyResources(this.dataGridViewVms, "dataGridViewVms");
|
resources.ApplyResources(this.dataGridViewVms, "dataGridViewVms");
|
||||||
this.dataGridViewVms.MultiSelect = true;
|
this.dataGridViewVms.MultiSelect = true;
|
||||||
this.dataGridViewVms.Name = "dataGridViewVms";
|
this.dataGridViewVms.Name = "dataGridViewVms";
|
||||||
this.dataGridViewVms.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridViewVms_KeyDown);
|
|
||||||
this.dataGridViewVms.SelectionChanged += new System.EventHandler(this.dataGridViewVms_SelectionChanged);
|
this.dataGridViewVms.SelectionChanged += new System.EventHandler(this.dataGridViewVms_SelectionChanged);
|
||||||
|
this.dataGridViewVms.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridViewVms_KeyDown);
|
||||||
//
|
//
|
||||||
// colImage
|
// colImage
|
||||||
//
|
//
|
||||||
@ -200,6 +201,12 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
this.button1.Name = "button1";
|
this.button1.Name = "button1";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// bgWorker
|
||||||
|
//
|
||||||
|
this.bgWorker.WorkerSupportsCancellation = true;
|
||||||
|
this.bgWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bgWorker_DoWork);
|
||||||
|
this.bgWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bgWorker_RunWorkerCompleted);
|
||||||
|
//
|
||||||
// AssignPriorities
|
// AssignPriorities
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this, "$this");
|
resources.ApplyResources(this, "$this");
|
||||||
@ -239,6 +246,7 @@ namespace XenAdmin.Wizards.HAWizard_Pages
|
|||||||
private System.Windows.Forms.DataGridViewTextBoxColumn colStartOrder;
|
private System.Windows.Forms.DataGridViewTextBoxColumn colStartOrder;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn colDelay;
|
private System.Windows.Forms.DataGridViewTextBoxColumn colDelay;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn colAgile;
|
private System.Windows.Forms.DataGridViewTextBoxColumn colAgile;
|
||||||
|
private System.ComponentModel.BackgroundWorker bgWorker;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -504,57 +504,21 @@
|
|||||||
<metadata name="colImage.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colImage.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colImage.HeaderText" xml:space="preserve">
|
|
||||||
<value />
|
|
||||||
</data>
|
|
||||||
<data name="colImage.Width" type="System.Int32, mscorlib">
|
|
||||||
<value>5</value>
|
|
||||||
</data>
|
|
||||||
<metadata name="colVm.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colVm.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colVm.HeaderText" xml:space="preserve">
|
|
||||||
<value>Virtual machine</value>
|
|
||||||
</data>
|
|
||||||
<data name="colVm.MinimumWidth" type="System.Int32, mscorlib">
|
|
||||||
<value>50</value>
|
|
||||||
</data>
|
|
||||||
<metadata name="colRestartPriority.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colRestartPriority.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colRestartPriority.HeaderText" xml:space="preserve">
|
|
||||||
<value>Restart priority</value>
|
|
||||||
</data>
|
|
||||||
<data name="colRestartPriority.MinimumWidth" type="System.Int32, mscorlib">
|
|
||||||
<value>50</value>
|
|
||||||
</data>
|
|
||||||
<metadata name="colStartOrder.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colStartOrder.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colStartOrder.HeaderText" xml:space="preserve">
|
|
||||||
<value>Start order</value>
|
|
||||||
</data>
|
|
||||||
<data name="colStartOrder.MinimumWidth" type="System.Int32, mscorlib">
|
|
||||||
<value>50</value>
|
|
||||||
</data>
|
|
||||||
<metadata name="colDelay.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colDelay.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colDelay.HeaderText" xml:space="preserve">
|
|
||||||
<value>Delay interval</value>
|
|
||||||
</data>
|
|
||||||
<data name="colDelay.MinimumWidth" type="System.Int32, mscorlib">
|
|
||||||
<value>50</value>
|
|
||||||
</data>
|
|
||||||
<metadata name="colAgile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="colAgile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="colAgile.HeaderText" xml:space="preserve">
|
|
||||||
<value>Agile</value>
|
|
||||||
</data>
|
|
||||||
<data name="colAgile.MinimumWidth" type="System.Int32, mscorlib">
|
|
||||||
<value>50</value>
|
|
||||||
</data>
|
|
||||||
<data name="dataGridViewVms.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
<data name="dataGridViewVms.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||||
<value>Fill</value>
|
<value>Fill</value>
|
||||||
</data>
|
</data>
|
||||||
@ -615,6 +579,60 @@
|
|||||||
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
||||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxStatus" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelHaStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="5" /><Control Name="labelProtectionLevel" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="m_dropDownButtonRestartPriority" Row="2" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="labelStartOrder" Row="3" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="nudOrder" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="labelStartDelay" Row="4" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="nudStartDelay" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="labelStartDelayUnits" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="linkLabelTellMeMore" Row="5" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="haNtolIndicator" Row="2" RowSpan="4" Column="5" ColumnSpan="1" /><Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="6" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings></value>
|
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxStatus" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelHaStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="5" /><Control Name="labelProtectionLevel" Row="2" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="m_dropDownButtonRestartPriority" Row="2" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="labelStartOrder" Row="3" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="nudOrder" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="labelStartDelay" Row="4" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="nudStartDelay" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="labelStartDelayUnits" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="linkLabelTellMeMore" Row="5" RowSpan="1" Column="0" ColumnSpan="5" /><Control Name="haNtolIndicator" Row="2" RowSpan="4" Column="5" ColumnSpan="1" /><Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="6" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings></value>
|
||||||
</data>
|
</data>
|
||||||
|
<metadata name="colImage.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colImage.HeaderText" xml:space="preserve">
|
||||||
|
<value />
|
||||||
|
</data>
|
||||||
|
<data name="colImage.Width" type="System.Int32, mscorlib">
|
||||||
|
<value>5</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="colVm.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colVm.HeaderText" xml:space="preserve">
|
||||||
|
<value>Virtual machine</value>
|
||||||
|
</data>
|
||||||
|
<data name="colVm.MinimumWidth" type="System.Int32, mscorlib">
|
||||||
|
<value>50</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="colRestartPriority.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colRestartPriority.HeaderText" xml:space="preserve">
|
||||||
|
<value>Restart priority</value>
|
||||||
|
</data>
|
||||||
|
<data name="colRestartPriority.MinimumWidth" type="System.Int32, mscorlib">
|
||||||
|
<value>50</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="colStartOrder.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colStartOrder.HeaderText" xml:space="preserve">
|
||||||
|
<value>Start order</value>
|
||||||
|
</data>
|
||||||
|
<data name="colStartOrder.MinimumWidth" type="System.Int32, mscorlib">
|
||||||
|
<value>50</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="colDelay.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colDelay.HeaderText" xml:space="preserve">
|
||||||
|
<value>Delay interval</value>
|
||||||
|
</data>
|
||||||
|
<data name="colDelay.MinimumWidth" type="System.Int32, mscorlib">
|
||||||
|
<value>50</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="colAgile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="colAgile.HeaderText" xml:space="preserve">
|
||||||
|
<value>Agile</value>
|
||||||
|
</data>
|
||||||
|
<data name="colAgile.MinimumWidth" type="System.Int32, mscorlib">
|
||||||
|
<value>50</value>
|
||||||
|
</data>
|
||||||
<data name="button1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
<data name="button1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||||
<value>NoControl</value>
|
<value>NoControl</value>
|
||||||
</data>
|
</data>
|
||||||
@ -636,6 +654,9 @@
|
|||||||
<data name=">>button1.Type" xml:space="preserve">
|
<data name=">>button1.Type" xml:space="preserve">
|
||||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
|
<metadata name="bgWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>166, 17</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
@ -690,6 +711,12 @@
|
|||||||
<data name=">>colAgile.Type" xml:space="preserve">
|
<data name=">>colAgile.Type" xml:space="preserve">
|
||||||
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name=">>bgWorker.Name" xml:space="preserve">
|
||||||
|
<value>bgWorker</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>bgWorker.Type" xml:space="preserve">
|
||||||
|
<value>System.ComponentModel.BackgroundWorker, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
<data name=">>$this.Name" xml:space="preserve">
|
<data name=">>$this.Name" xml:space="preserve">
|
||||||
<value>AssignPriorities</value>
|
<value>AssignPriorities</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
/* Copyright (c) Citrix Systems, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms,
|
|
||||||
* with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above
|
|
||||||
* copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer in the documentation and/or other
|
|
||||||
* materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace XenCenterLib
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This is thread-safe
|
|
||||||
/// </summary>
|
|
||||||
public class QueuedBackgroundWorker:BackgroundWorker
|
|
||||||
{
|
|
||||||
private Queue<BackgroundWorker> Queue = new Queue<BackgroundWorker>();
|
|
||||||
|
|
||||||
private object _lock = new object();
|
|
||||||
|
|
||||||
public delegate object DoWorkQueuedEventHandler(object sender, object argument);
|
|
||||||
|
|
||||||
public void RunWorkerAsync(DoWorkQueuedEventHandler doWork, RunWorkerCompletedEventHandler workerCompleted)
|
|
||||||
{
|
|
||||||
BackgroundWorker bw = GetBackgroundWorker(doWork, workerCompleted);
|
|
||||||
|
|
||||||
Queue.Enqueue(bw);
|
|
||||||
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
if (Queue.Count == 1)
|
|
||||||
{
|
|
||||||
((BackgroundWorker)this.Queue.Peek()).RunWorkerAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BackgroundWorker GetBackgroundWorker(DoWorkQueuedEventHandler doWork, RunWorkerCompletedEventHandler workerCompleted)
|
|
||||||
{
|
|
||||||
BackgroundWorker bw = new BackgroundWorker();
|
|
||||||
bw.WorkerReportsProgress = false;
|
|
||||||
bw.WorkerSupportsCancellation = false;
|
|
||||||
|
|
||||||
bw.DoWork += (sender, args) =>
|
|
||||||
{
|
|
||||||
if (doWork != null)
|
|
||||||
{
|
|
||||||
args.Result=doWork(this, new DoWorkEventArgs(args.Argument));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bw.RunWorkerCompleted += (sender, args) =>
|
|
||||||
{
|
|
||||||
if (workerCompleted != null)
|
|
||||||
{
|
|
||||||
object result = args.Error == null ? args.Result : null;
|
|
||||||
workerCompleted(this,
|
|
||||||
new RunWorkerCompletedEventArgs(result, args.Error,
|
|
||||||
args.Cancelled));
|
|
||||||
}
|
|
||||||
Queue.Dequeue();
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
if (Queue.Count > 0)
|
|
||||||
{
|
|
||||||
((BackgroundWorker)this.Queue.Peek()).RunWorkerAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return bw;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -87,9 +87,6 @@
|
|||||||
<Compile Include="PathValidator.cs" />
|
<Compile Include="PathValidator.cs" />
|
||||||
<Compile Include="Processes.cs" />
|
<Compile Include="Processes.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="QueuedBackgroundWorker.cs">
|
|
||||||
<SubType>Component</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Set.cs" />
|
<Compile Include="Set.cs" />
|
||||||
<Compile Include="StreamUtilities.cs" />
|
<Compile Include="StreamUtilities.cs" />
|
||||||
<Compile Include="StringUtility.cs" />
|
<Compile Include="StringUtility.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user