Changeset 6168 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs
- Timestamp:
- 05/09/11 14:12:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/RefreshableHiveExperiment.cs
r6110 r6168 35 35 private JobResultPoller jobResultPoller; 36 36 private JobDownloader<ItemJob> jobDownloader = new JobDownloader<ItemJob>(2, 2); 37 private static object locker = new object(); 37 38 38 39 [Storable] … … 66 67 get { return refreshAutomatically; } 67 68 set { 68 if (refreshAutomatically != value) { 69 refreshAutomatically = value; 70 OnRefreshAutomaticallyChanged(); 71 } 72 if (RefreshAutomatically && hiveExperiment.HiveJobs != null && hiveExperiment.HiveJobs.Count > 0 && (jobResultPoller == null || !jobResultPoller.IsPolling)) { 73 StartResultPolling(); 74 } else { 75 StopResultPolling(); 69 lock (locker) { 70 if (refreshAutomatically != value) { 71 refreshAutomatically = value; 72 OnRefreshAutomaticallyChanged(); 73 } 74 if (RefreshAutomatically) { 75 if (hiveExperiment.HiveJobs != null && hiveExperiment.HiveJobs.Count > 0 && (jobResultPoller == null || !jobResultPoller.IsPolling)) { 76 StartResultPolling(); 77 } 78 } else { 79 StopResultPolling(); 80 } 76 81 } 77 82 } … … 156 161 // lastJobDataUpdate equals DateTime.MinValue right after it was uploaded. When the first results are polled, this value is updated 157 162 if (lastJobDataUpdate != DateTime.MinValue && lastJobDataUpdate < hj.Job.LastJobDataUpdate) { 158 jobDownloader.DownloadJob(hj.Job.Id, (itemJob) => { 163 jobDownloader.DownloadJob(hj.Job.Id, (id, itemJob, exception) => { 164 if (exception != null) { 165 throw new JobDownloaderException("Downloading job failed.", exception); 166 } 167 159 168 if (itemJob == null) { 160 169 // something bad happened to this job. bad job, BAAAD job! … … 218 227 hiveExperiment.ExecutionTime = TimeSpan.FromMilliseconds(hiveExperiment.GetAllHiveJobs().Sum(x => x.Job.ExecutionTime.HasValue ? x.Job.ExecutionTime.Value.TotalMilliseconds : 0)); 219 228 } 220 221 public void OnLoaded() {222 this.UpdateTotalExecutionTime();223 224 if (hiveExperiment.ExecutionState != ExecutionState.Stopped) {225 this.RefreshAutomatically = true;226 }227 }228 229 #endregion 229 230 … … 235 236 hiveExperiment.ModifiedChanged += new EventHandler(hiveExperiment_ModifiedChanged); 236 237 hiveExperiment.IsProgressingChanged += new EventHandler(hiveExperiment_IsProgressingChanged); 238 hiveExperiment.Loaded += new EventHandler(hiveExperiment_Loaded); 237 239 } 238 240 … … 244 246 hiveExperiment.ModifiedChanged -= new EventHandler(hiveExperiment_ModifiedChanged); 245 247 hiveExperiment.IsProgressingChanged -= new EventHandler(hiveExperiment_IsProgressingChanged); 248 hiveExperiment.Loaded -= new EventHandler(hiveExperiment_Loaded); 249 } 250 251 private void hiveExperiment_Loaded(object sender, EventArgs e) { 252 this.UpdateTotalExecutionTime(); 253 254 if (hiveExperiment.ExecutionState != ExecutionState.Stopped) { 255 this.RefreshAutomatically = true; 256 } 246 257 } 247 258
Note: See TracChangeset
for help on using the changeset viewer.