- Timestamp:
- 01/16/13 11:13:18 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UnloadJobs/HeuristicLab.Clients.Hive/3.3/ConcurrentTaskDownloader.cs
r7259 r9169 30 30 /// Downloads and deserializes jobs. It avoids too many jobs beeing downloaded or deserialized at the same time to avoid memory problems 31 31 /// </summary> 32 public class ConcurrentTaskDownloader<T> where T : class, ITask {32 public class ConcurrentTaskDownloader<T> : IDisposable where T : class, ITask { 33 33 private bool abort = false; 34 34 // use semaphore to ensure only few concurrenct connections and few SerializedJob objects in memory … … 82 82 if (abort) return null; 83 83 result = HiveServiceLocator.Instance.CallHiveService(s => s.GetTaskData(task.Id)); 84 } finally { 84 } 85 finally { 85 86 downloadSemaphore.Release(); 86 87 } … … 95 96 taskData.Item2.Data = null; // reduce memory consumption. 96 97 return new Tuple<Task, T>(taskData.Item1, deserializedJob); 97 } finally { 98 } 99 finally { 98 100 deserializeSemaphore.Release(); 99 101 } … … 110 112 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 111 113 } 114 115 #region IDisposable Members 116 public void Dispose() { 117 TaskScheduler.UnobservedTaskException -= new EventHandler<UnobservedTaskExceptionEventArgs>(TaskScheduler_UnobservedTaskException); 118 deserializeSemaphore.Dispose(); 119 downloadSemaphore.Dispose(); 120 } 121 #endregion 112 122 } 113 123 }
Note: See TracChangeset
for help on using the changeset viewer.