Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5399


Ignore:
Timestamp:
01/31/11 10:35:57 (14 years ago)
Author:
cneumuel
Message:

#1260

  • fixed wiring of textboxes in HiveExperimentManager
  • robustified results polling in HiveExperimentManager
  • robustified HiveEngine
Location:
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager.Views/3.3/HiveExperimentListView.cs

    r4760 r5399  
    2828namespace HeuristicLab.Hive.ExperimentManager.Views {
    2929  [View("HiveExperimentList View")]
    30   [Content(typeof(HiveExperimentList), true)]
     30  [Content(typeof(HiveExperimentCollection), true)]
    3131  [Content(typeof(IItemList<HiveExperiment>), false)]
    32   public partial class HiveExperimentListView : ItemListView<HiveExperiment> {
     32  public partial class HiveExperimentListView : ItemCollectionView<HiveExperiment> {
    3333
    3434    public HiveExperimentListView() {
     
    4646      } else {
    4747        base.SetEnabledStateOfControls();
    48         if (Content != null) {
    49           if (itemsListView.SelectedItems.Count > 0) {
    50             // only allow delete-operation if all selected items are stored in hive (they have HiveExperimentId)
    51             bool canRemove = true;
    52             foreach (ListViewItem item in itemsListView.SelectedItems) {
    53               canRemove = canRemove && Content[item.Index].HiveExperimentId != Guid.Empty;
    54             }
    55             this.removeButton.Enabled = canRemove;
    56           }
    57         }
     48        this.removeButton.Enabled = Content != null && itemsListView.SelectedItems.Count > 0;
    5849      }
    5950    }
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager.Views/3.3/HiveJobView.Designer.cs

    r4760 r5399  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      this.stateLabel = new System.Windows.Forms.Label();
    2728      this.stateTextBox = new System.Windows.Forms.TextBox();
     
    5556      this.childHiveJobView = new HeuristicLab.Hive.ExperimentManager.Views.HiveJobListView();
    5657      this.runsTabPage = new System.Windows.Forms.TabPage();
     58      this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5759      this.logTabPage = new System.Windows.Forms.TabPage();
    5860      this.logView = new HeuristicLab.Core.Views.LogView();
    59       this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     61      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    6062      this.jobStatusGroupBox.SuspendLayout();
    6163      this.tabControl.SuspendLayout();
     
    6668      this.runsTabPage.SuspendLayout();
    6769      this.logTabPage.SuspendLayout();
     70      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6871      this.SuspendLayout();
    6972      //
     
    278281      this.priorityTextBox.Size = new System.Drawing.Size(496, 20);
    279282      this.priorityTextBox.TabIndex = 41;
     283      this.priorityTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.priorityTextBox_Validating);
     284      this.priorityTextBox.Validated += new System.EventHandler(this.priorityTextBox_Validated);
    280285      //
    281286      // priorityLabel
     
    296301      this.coresNeededTextBox.Size = new System.Drawing.Size(496, 20);
    297302      this.coresNeededTextBox.TabIndex = 37;
     303      this.coresNeededTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.coresNeededTextBox_Validating);
     304      this.coresNeededTextBox.Validated += new System.EventHandler(this.coresNeededTextBox_Validated);
    298305      //
    299306      // memoryNeededTextBox
     
    305312      this.memoryNeededTextBox.Size = new System.Drawing.Size(496, 20);
    306313      this.memoryNeededTextBox.TabIndex = 38;
     314      this.memoryNeededTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.memoryNeededTextBox_Validating);
     315      this.memoryNeededTextBox.Validated += new System.EventHandler(this.memoryNeededTextBox_Validated);
    307316      //
    308317      // memoryNeededLabel
     
    393402      this.runsTabPage.Text = "Runs";
    394403      this.runsTabPage.UseVisualStyleBackColor = true;
     404      //
     405      // runCollectionViewHost
     406      //
     407      this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     408                  | System.Windows.Forms.AnchorStyles.Left)
     409                  | System.Windows.Forms.AnchorStyles.Right)));
     410      this.runCollectionViewHost.Caption = "View";
     411      this.runCollectionViewHost.Content = null;
     412      this.runCollectionViewHost.Enabled = false;
     413      this.runCollectionViewHost.Location = new System.Drawing.Point(3, 3);
     414      this.runCollectionViewHost.Name = "runCollectionViewHost";
     415      this.runCollectionViewHost.ReadOnly = false;
     416      this.runCollectionViewHost.Size = new System.Drawing.Size(613, 486);
     417      this.runCollectionViewHost.TabIndex = 0;
     418      this.runCollectionViewHost.ViewsLabelVisible = true;
     419      this.runCollectionViewHost.ViewType = null;
    395420      //
    396421      // logTabPage
     
    418443      this.logView.TabIndex = 0;
    419444      //
    420       // runCollectionViewHost
    421       //
    422       this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    423                   | System.Windows.Forms.AnchorStyles.Left)
    424                   | System.Windows.Forms.AnchorStyles.Right)));
    425       this.runCollectionViewHost.Caption = "View";
    426       this.runCollectionViewHost.Content = null;
    427       this.runCollectionViewHost.Enabled = false;
    428       this.runCollectionViewHost.Location = new System.Drawing.Point(3, 3);
    429       this.runCollectionViewHost.Name = "runCollectionViewHost";
    430       this.runCollectionViewHost.ReadOnly = false;
    431       this.runCollectionViewHost.Size = new System.Drawing.Size(613, 486);
    432       this.runCollectionViewHost.TabIndex = 0;
    433       this.runCollectionViewHost.ViewType = null;
     445      // errorProvider
     446      //
     447      this.errorProvider.ContainerControl = this;
    434448      //
    435449      // HiveJobView
     
    451465      this.runsTabPage.ResumeLayout(false);
    452466      this.logTabPage.ResumeLayout(false);
     467      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    453468      this.ResumeLayout(false);
    454469
     
    491506    private System.Windows.Forms.TabPage runsTabPage;
    492507    private MainForm.WindowsForms.ViewHost runCollectionViewHost;
     508    private System.Windows.Forms.ErrorProvider errorProvider;
    493509  }
    494510}
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager.Views/3.3/HiveJobView.cs

    r4760 r5399  
    2424using HeuristicLab.Core.Views;
    2525using HeuristicLab.MainForm;
     26using System.Text;
     27using HeuristicLab.Data;
    2628
    2729namespace HeuristicLab.Hive.ExperimentManager.Views {
     
    7173      Content_JobStateChanged(this, EventArgs.Empty);
    7274    }
    73 
    74     void Content_JobChanged(object sender, EventArgs e) {
     75   
     76    private void RegisterJobEvents() {
     77      if (Content != null && Content.Job != null) {
     78        Content.Job.ComputeInParallelChanged += new EventHandler(Job_ComputeInParallelChanged);
     79        Content.Job.OptimizerChanged += new EventHandler(Job_OptimizerChanged);
     80      }
     81    }
     82
     83    private void DeregisterJobEvents() {
     84      if (Content != null && Content.Job != null) {
     85        Content.Job.ComputeInParallelChanged -= new EventHandler(Job_ComputeInParallelChanged);
     86        Content.Job.OptimizerChanged -= new EventHandler(Job_OptimizerChanged);
     87      }
     88    }
     89
     90    #region Content Events 
     91    private void Content_JobChanged(object sender, EventArgs e) {
    7592      RegisterJobEvents();
    7693      Job_OptimizerChanged(this, e);
    7794    }
    7895
    79     void Job_OptimizerChanged(object sender, EventArgs e) {
    80       if (Content != null && Content.Job != null && Content.Job.Optimizer != null) {
    81         optimizerNamedItemView.Content = Content.Job.Optimizer;
    82         runCollectionViewHost.Content = Content.Job.Optimizer.Runs;
    83       } else {
    84         optimizerNamedItemView.Content = null;
    85         runCollectionViewHost.Content = null;
    86       }
    87     }
    88 
    89     private void RegisterJobEvents() {
    90       if (Content != null && Content.Job != null) {
    91         Content.Job.ComputeInParallelChanged += new EventHandler(Job_ComputeInParallelChanged);
    92         Content.Job.OptimizerChanged += new EventHandler(Job_OptimizerChanged);
    93       }
    94     }
    95 
    96     private void DeregisterJobEvents() {
    97       if (Content != null && Content.Job != null) {
    98         Content.Job.ComputeInParallelChanged -= new EventHandler(Job_ComputeInParallelChanged);
    99         Content.Job.OptimizerChanged -= new EventHandler(Job_OptimizerChanged);
    100       }
    101     }
    102 
    103     #region Content Events
    10496    private void Content_JobDtoChanged(object sender, EventArgs e) {
    10597      if (InvokeRequired) {
     
    141133      }
    142134    }
     135   
     136    private void Job_OptimizerChanged(object sender, EventArgs e) {
     137      if (Content != null && Content.Job != null && Content.Job.Optimizer != null) {
     138        optimizerNamedItemView.Content = Content.Job.Optimizer;
     139        runCollectionViewHost.Content = Content.Job.Optimizer.Runs;
     140      } else {
     141        optimizerNamedItemView.Content = null;
     142        runCollectionViewHost.Content = null;
     143      }
     144    }
     145
     146    private void Job_ComputeInParallelChanged(object sender, EventArgs e) {
     147      if (InvokeRequired) {
     148        Invoke(new EventHandler(Job_ComputeInParallelChanged), sender, e);
     149      } else {
     150        computeInParallelCheckBox.Checked = Content.Job.ComputeInParallel;
     151        ShowOrHideChildJobTabPage();
     152      }
     153    }
     154
     155    private void ShowOrHideChildJobTabPage() {
     156      if (Content != null && Content.Job != null) {
     157        if (!Content.Job.ComputeInParallel) {
     158          if (tabControl.TabPages.Contains(childJobsTabPage))
     159            tabControl.TabPages.Remove(childJobsTabPage);
     160        } else {
     161          if (!tabControl.TabPages.Contains(childJobsTabPage))
     162            tabControl.TabPages.Insert(1, childJobsTabPage);
     163        }
     164      }
     165    }
     166    #endregion
    143167
    144168    protected override void SetEnabledStateOfControls() {
     
    165189    }
    166190
    167     void Job_ComputeInParallelChanged(object sender, EventArgs e) {
    168       if (InvokeRequired) {
    169         Invoke(new EventHandler(Job_ComputeInParallelChanged), sender, e);
    170       } else {
    171         computeInParallelCheckBox.Checked = Content.Job.ComputeInParallel;
    172         ShowOrHideChildJobTabPage();
    173       }
    174     }
    175 
    176     private void ShowOrHideChildJobTabPage() {
    177       if (Content != null && Content.Job != null) {
    178         if (!Content.Job.ComputeInParallel) {
    179           if (tabControl.TabPages.Contains(childJobsTabPage))
    180             tabControl.TabPages.Remove(childJobsTabPage);
    181         } else {
    182           if (!tabControl.TabPages.Contains(childJobsTabPage))
    183             tabControl.TabPages.Insert(1, childJobsTabPage);
    184         }
    185       }
     191    #region Control Events
     192    private void computeInParallelCheckBox_CheckedChanged(object sender, EventArgs e) {
     193      if (Content != null) this.Content.Job.ComputeInParallel = this.computeInParallelCheckBox.Checked;
     194    }
     195
     196    private void coresNeededTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
     197      int val;
     198      if ((!string.IsNullOrEmpty(coresNeededTextBox.Text)) && (!int.TryParse(coresNeededTextBox.Text, out val))) {
     199        e.Cancel = true;
     200        StringBuilder sb = new StringBuilder();
     201        sb.Append("Invalid Value (Valid Value Format: \"");
     202        sb.Append(FormatPatterns.GetIntFormatPattern());
     203        sb.Append("\")");
     204        errorProvider.SetError(coresNeededTextBox, sb.ToString());
     205        coresNeededTextBox.SelectAll();
     206      }
     207    }
     208
     209    private void coresNeededTextBox_Validated(object sender, EventArgs e) {
     210      if (string.IsNullOrEmpty(coresNeededTextBox.Text)) Content.JobDto.CoresNeeded = 1;
     211      else Content.JobDto.CoresNeeded = int.Parse(coresNeededTextBox.Text);
     212      errorProvider.SetError(coresNeededTextBox, string.Empty);
     213    }
     214
     215    private void memoryNeededTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
     216      int val;
     217      if ((!string.IsNullOrEmpty(memoryNeededTextBox.Text)) && (!int.TryParse(memoryNeededTextBox.Text, out val))) {
     218        e.Cancel = true;
     219        StringBuilder sb = new StringBuilder();
     220        sb.Append("Invalid Value (Valid Value Format: \"");
     221        sb.Append(FormatPatterns.GetIntFormatPattern());
     222        sb.Append("\")");
     223        errorProvider.SetError(memoryNeededTextBox, sb.ToString());
     224        memoryNeededTextBox.SelectAll();
     225      }
     226    }
     227
     228    private void memoryNeededTextBox_Validated(object sender, EventArgs e) {
     229      if (string.IsNullOrEmpty(memoryNeededTextBox.Text)) Content.JobDto.MemoryNeeded = 0;
     230      else Content.JobDto.MemoryNeeded = int.Parse(memoryNeededTextBox.Text);
     231      errorProvider.SetError(memoryNeededTextBox, string.Empty);
     232    }
     233
     234    private void priorityTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
     235      int val;
     236      if ((!string.IsNullOrEmpty(priorityTextBox.Text)) && (!int.TryParse(priorityTextBox.Text, out val))) {
     237        e.Cancel = true;
     238        StringBuilder sb = new StringBuilder();
     239        sb.Append("Invalid Value (Valid Value Format: \"");
     240        sb.Append(FormatPatterns.GetIntFormatPattern());
     241        sb.Append("\")");
     242        errorProvider.SetError(priorityTextBox, sb.ToString());
     243        priorityTextBox.SelectAll();
     244      }
     245    }
     246
     247    private void priorityTextBox_Validated(object sender, EventArgs e) {
     248      if (string.IsNullOrEmpty(priorityTextBox.Text)) Content.JobDto.Priority = 0;
     249      else Content.JobDto.Priority = int.Parse(priorityTextBox.Text);
     250      errorProvider.SetError(priorityTextBox, string.Empty);
    186251    }
    187252    #endregion
    188253
    189     private void computeInParallelCheckBox_CheckedChanged(object sender, EventArgs e) {
    190       if (Content != null) {
    191         this.Content.Job.ComputeInParallel = this.computeInParallelCheckBox.Checked;
    192       }
    193     }
    194254  }
    195255}
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager.Views/3.3/HiveJobView.resx

    r4423 r5399  
    113113  </resheader>
    114114  <resheader name="reader">
    115     <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     115    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    116116  </resheader>
    117117  <resheader name="writer">
    118     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager/3.3/HiveExperimentList.cs

    r4760 r5399  
    2626
    2727namespace HeuristicLab.Hive.ExperimentManager {
    28   [Item("HiveExperiment List", "Represents a list of hive experiments.")]
     28  [Item("HiveExperiment Collection", "Represents a list of hive experiments.")]
    2929  [StorableClass]
    30   public class HiveExperimentList : ItemList<HiveExperiment> {
    31     public HiveExperimentList() : base() { }
    32     public HiveExperimentList(int capacity) : base(capacity) { }
    33     public HiveExperimentList(IEnumerable<HiveExperiment> collection) : base(collection) { }
     30  public class HiveExperimentCollection : ItemCollection<HiveExperiment> {
     31    public HiveExperimentCollection() : base() { }
     32    public HiveExperimentCollection(int capacity) : base(capacity) { }
     33    public HiveExperimentCollection(IEnumerable<HiveExperiment> collection) : base(collection) { }
    3434
    3535    [StorableConstructor]
    36     protected HiveExperimentList(bool deserializing) : base(deserializing) { }
    37     protected HiveExperimentList(HiveExperimentList original, Cloner cloner)
     36    protected HiveExperimentCollection(bool deserializing) : base(deserializing) { }
     37    protected HiveExperimentCollection(HiveExperimentCollection original, Cloner cloner)
    3838      : base(original, cloner) {
    3939    }
    4040    public override IDeepCloneable Clone(Cloner cloner) {
    41       return new HiveExperimentList(this, cloner);
     41      return new HiveExperimentCollection(this, cloner);
    4242    }
    4343  }
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager/3.3/HiveExperimentManager.cs

    r4914 r5399  
    4242    }
    4343
    44     private HiveExperimentList hiveExperiments;
    45     public HiveExperimentList HiveExperiments {
     44    private HiveExperimentCollection hiveExperiments;
     45    public HiveExperimentCollection HiveExperiments {
    4646      get { return hiveExperiments; }
    4747      set {
     
    7373    private void RegisterHiveExperimentsEvent() {
    7474      if (hiveExperiments != null) {
    75         hiveExperiments.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<HiveExperiment>>(hiveExperiments_ItemsRemoved);
     75        hiveExperiments.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveExperiment>(hiveExperiments_ItemsRemoved);
    7676      }
    7777    }
     
    7979    private void DeRegisterHiveExperimentsEvents() {
    8080      if (hiveExperiments != null) {
    81         hiveExperiments.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<HiveExperiment>>(hiveExperiments_ItemsRemoved);
     81        hiveExperiments.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveExperiment>(hiveExperiments_ItemsRemoved);
    8282      }
    8383    }
     
    100100        IsProgressing = true;
    101101        if (this.HiveExperiments == null) {
    102           this.HiveExperiments = new HiveExperimentList();
     102          this.HiveExperiments = new HiveExperimentCollection();
    103103        }
    104104        using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) {
     
    149149    }
    150150
    151     void hiveExperiments_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<HiveExperiment>> e) {
     151    void hiveExperiments_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<HiveExperiment> e) {
    152152      if (!currentlyUpdating) {
    153153        using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) {
    154           foreach (IndexedItem<HiveExperiment> item in e.Items) {
    155             if (item.Value.HiveExperimentId != Guid.Empty) {
    156               service.Obj.DeleteHiveExperiment(item.Value.HiveExperimentId);
     154          foreach (HiveExperiment item in e.Items) {
     155            if (item.HiveExperimentId != Guid.Empty) {
     156              service.Obj.DeleteHiveExperiment(item.HiveExperimentId);
    157157            }
    158158          }
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.ExperimentManager/3.3/JobResultPoller.cs

    r4914 r5399  
    9292      catch (Exception e) {
    9393        OnExceptionOccured(e);
     94        IsPolling = false;
    9495      }
    9596    }
    9697
    9798    private void FetchJobResults() {
    98       ResponseObject<JobResultList> response;
    99       using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) {
    100         response = service.Obj.GetChildJobResults(hiveJob.JobDto.Id, true, true);
     99      int repetitions = 5;
     100      ResponseObject<JobResultList> response = null;
     101      while (response == null && repetitions > 0) {
     102        repetitions--;
     103        try {
     104          using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) {
     105            response = service.Obj.GetChildJobResults(hiveJob.JobDto.Id, true, true);
     106          }
     107        }
     108        catch (Exception e) {
     109          if (repetitions == 0)
     110            throw e;
     111        }
    101112      }
    102113      if (response.StatusMessage == ResponseStatus.Ok) {
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs

    r5394 r5399  
    5151      }
    5252    }
    53    
     53
    5454    #region constructors and cloning
    5555    public HiveEngine() {
     
    310310    private void DeleteJobs(IDictionary<Guid, int> jobIndices) {
    311311      if (jobIndices.Count > 0) {
    312         using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) {
    313           foreach (Guid jobId in jobIndices.Keys) {
    314             service.Obj.DeleteJob(jobId);
    315           }
    316           LogMessage(string.Format("Deleted {0} jobs on hive.", jobIndices.Count));
    317           jobIndices.Clear();
    318         }
     312        TryAndRepeat(() => {
     313          LogMessage(string.Format("Deleting {0} jobs on hive.", jobIndices.Count));
     314          using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) {
     315            foreach (Guid jobId in jobIndices.Keys) {
     316              service.Obj.DeleteJob(jobId);
     317            }
     318            jobIndices.Clear();
     319          }
     320        }, 5, string.Format("Could not delete {0} jobs", jobIndices.Count));
    319321      }
    320322    }
     
    364366            catch (Exception e) {
    365367              LogException(e);
     368              LogMessage("Repeating upload");
    366369            }
    367370          }
     
    393396          catch (Exception e) {
    394397            LogException(e);
     398            LogMessage("Repeating download");
    395399          }
    396400        }
     
    423427      }
    424428    }
     429
     430    /// <summary>
     431    /// Executes the action. If it throws an exception it is repeated until repetition-count is reached.
     432    /// If repetitions is -1, it is repeated infinitely.
     433    /// </summary>
     434    private static void TryAndRepeat(Action action, int repetitions, string errorMessage) {
     435      while (repetitions > 0) {
     436        try { action(); }
     437        catch (Exception e) {
     438          repetitions--;
     439          if (repetitions == 0) {
     440            throw new HiveEngineException(errorMessage, e);
     441          }
     442        }
     443      }
     444    }
     445
     446    private static void TryAndRepeat(Action action) {
     447      TryAndRepeat(action, -1, string.Empty);
     448    }
    425449  }
    426450
  • branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngineException.cs

    r5228 r5399  
    77  public class HiveEngineException : Exception {
    88    public HiveEngineException(string message) : base(message) { }
     9
     10    public HiveEngineException(string message, Exception innerException) : base (message, innerException) { }
    911  }
    1012}
Note: See TracChangeset for help on using the changeset viewer.