Renamed methods so it's more obvious what they do.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-05-24 17:21:43 +01:00 committed by Mihaela Stoica
parent 57ab2ced2b
commit 2c3c4bf5ca
2 changed files with 13 additions and 17 deletions

View File

@ -94,33 +94,31 @@ namespace XenAdmin.Wizards.GenericPages
/// <summary>
/// Create a thread and fetch the reason
/// </summary>
public void Load()
public void LoadAsync()
{
//Set default reason without going through setter so not to trigger the event
//Set default reason without going through setter so as not to trigger the event
failureReason = Messages.DELAY_LOADING_COMBO_BOX_WAITING;
//Thread will trigger event when setting the reason
FetchReasonAsnyc();
ThreadPool.QueueUserWorkItem(delegate { FetchFailureReasonWithRetry(defaultRetries, defaultTimeOut); });
}
//Fetch the reason, no thread
public void LoadAndWait()
/// <summary>
/// Fetch the reason on the current thread
/// </summary>
public void LoadSync()
{
FetchFailureReasonWithRetry(defaultRetries, defaultTimeOut);
}
private void FetchReasonAsnyc()
{
ThreadPool.QueueUserWorkItem(delegate { FetchFailureReasonWithRetry(defaultRetries, defaultTimeOut); });
}
public void CancelFilters()
{
foreach (ReasoningFilter filter in _filters)
filter.Cancel();
}
/// <summary>
/// Triggers event when setting the reason
/// </summary>
private void FetchFailureReasonWithRetry(int retries, int timeOut)
{
string threadFailureReason = Messages.DELAY_LOADED_COMBO_BOX_ITEM_FAILURE_UNKOWN;

View File

@ -286,7 +286,7 @@ namespace XenAdmin.Wizards.GenericPages
item = CreateDelayLoadingOptionComboBoxItem(host);
m_comboBoxConnection.Items.Add(item);
item.ReasonUpdated += DelayLoadedComboBoxItem_ReasonChanged;
item.Load();
item.LoadAsync();
host.PropertyChanged -= PropertyChanged;
host.PropertyChanged += PropertyChanged;
}
@ -296,7 +296,7 @@ namespace XenAdmin.Wizards.GenericPages
item = CreateDelayLoadingOptionComboBoxItem(pool);
m_comboBoxConnection.Items.Add(item);
item.ReasonUpdated += DelayLoadedComboBoxItem_ReasonChanged;
item.Load();
item.LoadAsync();
pool.PropertyChanged -= PropertyChanged;
pool.PropertyChanged += PropertyChanged;
}
@ -406,12 +406,10 @@ namespace XenAdmin.Wizards.GenericPages
var sortedHosts = new List<Host>(Connection.Cache.Hosts);
sortedHosts.Sort();
var items = new List<DelayLoadingOptionComboBoxItem>();
foreach (var host in sortedHosts)
{
var item = new DelayLoadingOptionComboBoxItem(host, homeserverFilters);
item.LoadAndWait();
item.LoadSync();
cb.Items.Add(item);
if (item.Enabled && ((m_selectedObject != null && m_selectedObject.opaque_ref == host.opaque_ref) ||
(target != null && target.Item.opaque_ref == host.opaque_ref)))