- Timestamp:
- 01/16/13 11:13:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs
r7259 r9169 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using HeuristicLab.Clients.Hive.Jobs; 26 27 using HeuristicLab.Common; 27 using System.Threading;28 28 29 29 namespace HeuristicLab.Clients.Hive { 30 public class TaskDownloader {30 public class TaskDownloader : IDisposable { 31 31 private IEnumerable<Guid> taskIds; 32 32 private ConcurrentTaskDownloader<ItemTask> taskDownloader; … … 38 38 public bool IsFinished { 39 39 get { 40 try { 41 resultsLock.EnterReadLock(); 42 return results.Count == taskIds.Count(); 43 } finally { resultsLock.ExitReadLock(); } 40 try { 41 resultsLock.EnterReadLock(); 42 return results.Count == taskIds.Count(); 43 } 44 finally { resultsLock.ExitReadLock(); } 44 45 } 45 46 } … … 59 60 public int FinishedCount { 60 61 get { 61 try { 62 resultsLock.EnterReadLock(); 63 return results.Count; 64 } finally { resultsLock.ExitReadLock(); } 62 try { 63 resultsLock.EnterReadLock(); 64 return results.Count; 65 } 66 finally { resultsLock.ExitReadLock(); } 65 67 } 66 68 } … … 68 70 public IDictionary<Guid, HiveTask> Results { 69 71 get { 70 try { 71 resultsLock.EnterReadLock(); 72 return results; 73 } finally { resultsLock.ExitReadLock(); } 72 try { 73 resultsLock.EnterReadLock(); 74 return results; 75 } 76 finally { resultsLock.ExitReadLock(); } 74 77 } 75 78 } … … 97 100 resultsLock.EnterWriteLock(); 98 101 this.results.Add(localJob.Id, hiveTask); 99 } finally { resultsLock.ExitWriteLock(); } 102 } 103 finally { resultsLock.ExitWriteLock(); } 100 104 } 101 105 }); … … 114 118 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 115 119 } 120 121 #region IDisposable Members 122 public void Dispose() { 123 taskDownloader.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured); 124 resultsLock.Dispose(); 125 } 126 #endregion 116 127 } 117 128 }
Note: See TracChangeset
for help on using the changeset viewer.