Changeset 4120 for branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console
- Timestamp:
- 07/29/10 16:58:35 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/JobDataFetcher.cs
r4107 r4120 11 11 namespace HeuristicLab.Hive.Server.ServerConsole { 12 12 public class JobDataFetcher { 13 public List<State> PollStates { get; set; } 13 private List<State> pollStates; 14 15 public IEnumerable<State> PollStates { 16 get { return pollStates; } 17 } 14 18 15 19 public event EventHandler NewDataAvailable; 16 20 17 21 private System.Timers.Timer timer; 22 23 private static object locker = new object(); 18 24 19 25 public List<JobDto> CachedJobs { get; set; } … … 39 45 40 46 public JobDataFetcher(IEnumerable<State> states, int nrOfEntries) { 41 PollStates = new List<State>();47 pollStates = new List<State>(); 42 48 CachedJobs = new List<JobDto>(); 43 49 NrOfEntriesOnPage = nrOfEntries; 44 50 CurrentPage = 0; 45 PollStates.AddRange(states);51 pollStates.AddRange(states); 46 52 timer = new System.Timers.Timer(); 47 53 timer.Interval = 5000; … … 70 76 // [chn] Exception occured here: PollStates enumeration changed! 71 77 // todo: make access to PollStates thread-safe! 72 foreach (State stat in PollStates) { 73 ResponseList<JobDto> resList = ServiceLocator.GetJobManager().GetAllJobsWithFilter(stat, CurrentPage * NrOfEntriesOnPage, 74 NrOfEntriesOnPage); 75 if (resList.Success) { 76 if (resList.List.Count == 0) { 77 if (CurrentPage > 0) { 78 CurrentPage--; 78 // * added lock on locker -> didn't help 79 // * made public property PollStates an IEnumerable to be immutable -> lets see 80 lock (locker) { 81 foreach (State stat in PollStates) { 82 ResponseList<JobDto> resList = ServiceLocator.GetJobManager().GetAllJobsWithFilter(stat, CurrentPage * NrOfEntriesOnPage, 83 NrOfEntriesOnPage); 84 if (resList.Success) { 85 if (resList.List.Count == 0) { 86 if (CurrentPage > 0) { 87 CurrentPage--; 88 } 89 } else { 90 CachedJobs = new List<JobDto>(); 91 CachedJobs.AddRange(resList.List); 79 92 } 80 } else {81 CachedJobs = new List<JobDto>();82 CachedJobs.AddRange(resList.List);83 93 } 84 94 } 95 if (NewDataAvailable != null) 96 NewDataAvailable(this, new EventArgs()); 85 97 } 86 if (NewDataAvailable != null)87 NewDataAvailable(this, new EventArgs());88 98 } 89 99 }
Note: See TracChangeset
for help on using the changeset viewer.