Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 13:54:57 (13 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch

' removed pre-build event for multiple app.configs

Location:
branches/HeuristicLab.Hive.Azure
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3

    • Property svn:ignore
      •  

        old new  
        11obj
        22Plugin.cs
         3bin
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs

    r6976 r7215  
    2525using HeuristicLab.Clients.Hive.Jobs;
    2626using HeuristicLab.Common;
     27using System.Threading;
    2728
    2829namespace HeuristicLab.Clients.Hive {
     
    3334    private bool exceptionOccured = false;
    3435    private Exception currentException;
     36    private ReaderWriterLockSlim resultsLock = new ReaderWriterLockSlim();
    3537
    3638    public bool IsFinished {
    3739      get {
    38         return results.Count == taskIds.Count();
     40          try {       
     41              resultsLock.EnterReadLock();
     42              return results.Count == taskIds.Count();
     43          } finally { resultsLock.ExitReadLock(); }
    3944      }
    4045    }
     
    5156      }
    5257    }
    53    
     58
    5459    public int FinishedCount {
    5560      get {
    56         return results.Count;
     61            try {
     62              resultsLock.EnterReadLock();
     63              return results.Count;
     64             } finally { resultsLock.ExitReadLock(); }
    5765      }
    5866    }
     
    6068    public IDictionary<Guid, HiveTask> Results {
    6169      get {
    62         return results;
     70            try {
     71              resultsLock.EnterReadLock();
     72              return results;
     73            } finally { resultsLock.ExitReadLock(); }
    6374      }
    6475    }
     
    6677    public TaskDownloader(IEnumerable<Guid> jobIds) {
    6778      this.taskIds = jobIds;
    68       this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
     79      this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);
    6980      this.taskDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured);
    7081      this.results = new Dictionary<Guid, HiveTask>();
    7182    }
    72    
     83
    7384    public void StartAsync() {
    7485      foreach (Guid taskId in taskIds) {
    75         Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskId));
    76 
    77         taskDownloader.DownloadTask(task,
     86        taskDownloader.DownloadTaskDataAndTask(taskId,
    7887          (localJob, itemJob) => {
    7988            if (localJob != null && itemJob != null) {
     
    8594              }
    8695              hiveTask.Task = localJob;
    87               this.results.Add(localJob.Id, hiveTask);
     96              try {
     97                resultsLock.EnterWriteLock();
     98                this.results.Add(localJob.Id, hiveTask);
     99              } finally { resultsLock.ExitWriteLock(); }
    88100            }
    89101          });
    90       }     
     102      }
    91103    }
    92104
Note: See TracChangeset for help on using the changeset viewer.