Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/10 23:33:13 (14 years ago)
Author:
swagner
Message:

Finished refactoring of saving and loading items (#990)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3455 r3500  
    187187      openFileDialog.Title = "Open Problem";
    188188      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    189         this.Cursor = Cursors.AppStarting;
    190189        newProblemButton.Enabled = openProblemButton.Enabled = false;
    191190        problemViewHost.Enabled = false;
    192191
    193         var call = new Func<string, object>(XmlParser.Deserialize);
    194         call.BeginInvoke(openFileDialog.FileName, delegate(IAsyncResult a) {
    195           IProblem problem = null;
     192        ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
    196193          try {
    197             problem = call.EndInvoke(a) as IProblem;
    198           } catch (Exception ex) {
    199             Auxiliary.ShowErrorMessageBox(ex);
    200           }
    201           Invoke(new Action(delegate() {
     194            if (error != null) throw error;
     195            IProblem problem = content as IProblem;
    202196            if (problem == null)
    203197              MessageBox.Show(this, "The selected file does not contain a problem.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
     
    206200            else
    207201              Content.Problem = problem;
    208             problemViewHost.Enabled = true;
    209             newProblemButton.Enabled = openProblemButton.Enabled = true;
    210             this.Cursor = Cursors.Default;
    211           }));
    212         }, null);
     202          }
     203          catch (Exception ex) {
     204            Auxiliary.ShowErrorMessageBox(ex);
     205          }
     206          finally {
     207            Invoke(new Action(delegate() {
     208              problemViewHost.Enabled = true;
     209              newProblemButton.Enabled = openProblemButton.Enabled = true;
     210            }));
     211          }
     212        });
    213213      }
    214214    }
Note: See TracChangeset for help on using the changeset viewer.