Changeset 10488


Ignore:
Timestamp:
02/20/14 15:34:31 (5 years ago)
Author:
gkronber
Message:

#2155: remove the progress bar only after the last sample has been loaded (otherwise an exception occurs if at least two samples cannot be loaded)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs

    r9907 r10488  
    7070    private void LoadSamples(object state) {
    7171      progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...");
    72       Assembly assembly = Assembly.GetExecutingAssembly();
    73       var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl"));
    74       int count = samples.Count();
    75       string path = Path.GetTempFileName();
     72      try {
     73        Assembly assembly = Assembly.GetExecutingAssembly();
     74        var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl"));
     75        int count = samples.Count();
     76        string path = Path.GetTempFileName();
    7677
    77       foreach (string name in samples) {
    78         try {
    79           using (Stream stream = assembly.GetManifestResourceStream(name)) {
    80             WriteStreamToTempFile(stream, path);
    81             INamedItem item = XmlParser.Deserialize<INamedItem>(path);
    82             OnSampleLoaded(item, 1.0 / count);
     78        foreach (string name in samples) {
     79          try {
     80            using (Stream stream = assembly.GetManifestResourceStream(name)) {
     81              WriteStreamToTempFile(stream, path);
     82              INamedItem item = XmlParser.Deserialize<INamedItem>(path);
     83              OnSampleLoaded(item, 1.0 / count);
     84            }
     85          }
     86          catch (Exception) {
    8387          }
    8488        }
    85         catch (Exception) {
    86           MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
    87         }
     89        OnAllSamplesLoaded();
    8890      }
    89       OnAllSamplesLoaded();
     91      finally {
     92        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
     93      }
    9094    }
    9195    private void OnSampleLoaded(INamedItem sample, double progress) {
     
    111115            samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    112116        }
    113         MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
    114117      }
    115118    }
Note: See TracChangeset for help on using the changeset viewer.