mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CA-311146: Copy the results of a linq query to a list to prevent
enumeration on modified collection (it also improves efficiency). Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
977d2aa503
commit
2c884ea47f
@ -139,7 +139,7 @@ namespace XenAdmin.Controls
|
||||
|
||||
//remove one more as we're adding the selected further down
|
||||
//Take(arg) returns empty list if the arg <= 0
|
||||
var viewsToRemove = vncViews.Where(v => v.Key.opaque_ref != source.opaque_ref).Take(vncViews.Count -1 - MAX_ACTIVE_VM_CONSOLES);
|
||||
var viewsToRemove = vncViews.Where(v => v.Key.opaque_ref != source.opaque_ref).Take(vncViews.Count - 1 - MAX_ACTIVE_VM_CONSOLES).ToList();
|
||||
|
||||
foreach (var view in viewsToRemove)
|
||||
closeVNCForSource(view.Key);
|
||||
@ -305,8 +305,9 @@ namespace XenAdmin.Controls
|
||||
if (vncView == null)
|
||||
return;
|
||||
|
||||
// find the <VM, VNCView> pair in vncViews and start timer on the vm
|
||||
foreach (var kvp in vncViews.Where(kvp => kvp.Value == vncView))
|
||||
// find the <VM, VNCView> pair in vncViews and start timer on the vm
|
||||
var views = vncViews.Where(kvp => kvp.Value == vncView).ToList();
|
||||
foreach (var kvp in views)
|
||||
{
|
||||
StartCloseVNCTimer(kvp.Key);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user