Changeset 9173 for branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3
- Timestamp:
- 01/18/13 10:26:25 (12 years ago)
- Location:
- branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r9170 r9173 46 46 47 47 #region Properties 48 private ItemCollection<RefreshableJob> jobs;49 public ItemCollection<RefreshableJob> Jobs {48 private HiveItemCollection<RefreshableJob> jobs; 49 public HiveItemCollection<RefreshableJob> Jobs { 50 50 get { return jobs; } 51 51 set { … … 87 87 88 88 public void ClearHiveClient() { 89 Jobs.ClearWithoutHiveDeletion(); 89 90 foreach (var j in Jobs) { 90 91 if (j.RefreshAutomatically) { 91 92 j.RefreshAutomatically = false; // stop result polling 92 j.Dispose();93 }93 } 94 j.Dispose(); 94 95 } 95 96 Jobs = null; 97 96 98 if (onlinePlugins != null) 97 99 onlinePlugins.Clear(); -
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs
r8939 r9173 36 36 [Item("Hive Task", "Represents a hive task.")] 37 37 [StorableClass] 38 public class HiveTask : NamedItem, IItemTree<HiveTask> {38 public class HiveTask : NamedItem, IItemTree<HiveTask>, IDisposable { 39 39 protected static object locker = new object(); 40 40 protected ReaderWriterLockSlim childHiveTasksLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); … … 67 67 set { 68 68 if (task != value) { 69 Deregister JobEvents();69 DeregisterTaskEvents(); 70 70 task = value; 71 Register JobEvents();71 RegisterTaskEvents(); 72 72 IsFinishedTaskDownloaded = false; 73 73 OnTaskChanged(); … … 93 93 itemTaskLock.EnterWriteLock(); 94 94 try { 95 Der gisterItemTaskEvents();95 DeregisterItemTaskEvents(); 96 96 itemTask = value; 97 97 RegisterItemTaskEvents(); … … 177 177 this.childHiveTasks = new ItemList<HiveTask>(); 178 178 syncTasksWithOptimizers = true; 179 RegisterChildHive JobEvents();179 RegisterChildHiveTasksEvents(); 180 180 } 181 181 … … 198 198 this.childHiveTasks = new ItemList<HiveTask>(); 199 199 this.syncTasksWithOptimizers = true; 200 RegisterChildHive JobEvents();200 RegisterChildHiveTasksEvents(); 201 201 } 202 202 … … 226 226 } 227 227 } 228 protected virtual void Der gisterItemTaskEvents() {228 protected virtual void DeregisterItemTaskEvents() { 229 229 if (ItemTask != null) { 230 230 ItemTask.ComputeInParallelChanged -= new EventHandler(ItemJob_ComputeInParallelChanged); … … 233 233 } 234 234 235 protected virtual void RegisterChildHive JobEvents() {235 protected virtual void RegisterChildHiveTasksEvents() { 236 236 this.childHiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<HiveTask>>(OnItemsAdded); 237 237 this.childHiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<HiveTask>>(OnItemsRemoved); 238 238 this.childHiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<HiveTask>>(OnCollectionReset); 239 239 } 240 protected virtual void DeregisterChildHive JobEvents() {240 protected virtual void DeregisterChildHiveTasksEvents() { 241 241 this.childHiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<HiveTask>>(OnItemsAdded); 242 242 this.childHiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<HiveTask>>(OnItemsRemoved); … … 342 342 } 343 343 344 private void Register JobEvents() {344 private void RegisterTaskEvents() { 345 345 if (task != null) 346 346 task.PropertyChanged += new PropertyChangedEventHandler(task_PropertyChanged); 347 347 } 348 348 349 private void Deregister JobEvents() {349 private void DeregisterTaskEvents() { 350 350 if (task != null) 351 351 task.PropertyChanged += new PropertyChangedEventHandler(task_PropertyChanged); … … 526 526 this.ItemTask.Item = null; 527 527 } 528 529 public void Dispose() { 530 DeregisterChildHiveTasksEvents(); 531 DeregisterTaskEvents(); 532 DeregisterItemTaskEvents(); 533 childHiveTasksLock.Dispose(); 534 itemTaskLock.Dispose(); 535 } 528 536 } 529 537 -
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs
r8939 r9173 107 107 } 108 108 } 109 protected override void Der gisterItemTaskEvents() {110 base.Der gisterItemTaskEvents();109 protected override void DeregisterItemTaskEvents() { 110 base.DeregisterItemTaskEvents(); 111 111 if (ItemTask != null) { 112 112 if (ItemTask.Item is Optimization.Experiment) { -
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs
r9169 r9173 562 562 563 563 public Guid Id { 564 get { return job.Id; } 564 get { 565 if (job == null) return Guid.Empty; 566 return job.Id; 567 } 565 568 set { job.Id = value; } 566 569 } … … 614 617 jobDownloader = null; 615 618 } 619 if (jobResultPoller != null) { 620 DeregisterResultPollingEvents(); 621 jobResultPoller = null; 622 } 623 if (hiveTasks != null) { 624 DisposeTasks(); 625 } 616 626 if (job != null) { 617 627 DeregisterJobEvents(); 618 628 job = null; 619 629 } 620 if (hiveTasks != null) {621 DeregisterHiveTasksEvents(); 622 hiveTasks.Clear(); // this should remove the item_StateLogChanged event handlers623 hiveTasks = null;624 }625 if (jobResultPoller != null) {626 DeregisterResultPollingEvents();627 jobResultPoller = null;628 }630 } 631 632 private void DisposeTasks() { 633 DeregisterHiveTasksEvents(); 634 foreach (var task in hiveTasks) { 635 task.Dispose(); 636 } 637 hiveTasks.Clear(); // this should remove the item_StateLogChanged event handlers 638 hiveTasks = null; 629 639 } 630 640 #endregion -
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveItemCollection.cs
r7259 r9173 52 52 } 53 53 54 public void ClearWithoutHiveDeletion() { 55 if (list.Count > 0) { 56 T[] items = list.ToArray(); 57 list.Clear(); 58 OnPropertyChanged("Count"); 59 //don't call OnCollectionReset directly as it would delete the job 60 base.OnCollectionReset(list, items); 61 } 62 } 63 54 64 private void RemoveItems(IEnumerable<T> items, out IEnumerable<T> successful, out IEnumerable<T> unsuccessful, out Exception exception) { 55 65 List<T> removed = new List<T>();
Note: See TracChangeset
for help on using the changeset viewer.