Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15446


Ignore:
Timestamp:
11/03/17 11:14:27 (7 years ago)
Author:
pfleck
Message:

#2845:

  • Start progres with initial progress value in several cases to use the progress value update.
  • Removed object disposal guard in ProgressView because it can block part of the initialization.
Location:
branches/EnhancedProgress
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/EnhancedProgress/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs

    r14185 r15446  
    273273      var task = Task.Factory.StartNew(() => {
    274274        sem.Wait();
    275         progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");
     275        progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...", 0);
    276276        RebuildDataTable(resultName, rowName);
    277277      });
  • branches/EnhancedProgress/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15415 r15446  
    284284        // upload tasks
    285285        refreshableJob.Progress.Message = "Uploading tasks...";
    286 
     286        refreshableJob.Progress.ProgressBarMode = ProgressBarMode.Continuous;
     287        refreshableJob.Progress.ProgressValue = 0;
     288       
    287289        var tasks = new List<TS.Task>();
    288290        foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
     
    417419
    418420        refreshableJob.Progress.Message = "Downloading tasks...";
     421        refreshableJob.Progress.ProgressBarMode = ProgressBarMode.Continuous;
     422        refreshableJob.Progress.ProgressValue = 0.0;
    419423        downloader = new TaskDownloader(allTasks.Select(x => x.Id));
    420424        downloader.StartAsync();
     
    433437
    434438        refreshableJob.Progress.Message = "Downloading/deserializing complete. Displaying tasks...";
     439        refreshableJob.Progress.ProgressBarMode = ProgressBarMode.Marquee;
     440
    435441        // build child-task tree
    436442        foreach (HiveTask hiveTask in parents) {
  • branches/EnhancedProgress/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs

    r14185 r15446  
    210210    private void UploadAsync() {
    211211      var message = "Uploading runs to OKB...";
    212       IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
     212      IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message, 0);
    213213      double count = dataGridView.Rows.Count;
    214214      int i = 0;
  • branches/EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r15370 r15446  
    174174
    175175          try {
    176             var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");
     176            var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.", 0);
    177177
    178178            instanceProvider.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; };
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r15445 r15446  
    158158
    159159    private void UpdateProgressValue() {
    160       // prevent problems with object disposal and invoke as suggested by http://stackoverflow.com/a/18647091
    161       if (!IsHandleCreated) return;
    162160      if (InvokeRequired) {
    163         try {
    164           Invoke((Action)UpdateProgressValue);
    165         } catch (InvalidOperationException) {
    166           // swallow ObjectDisposedException
    167           // which might occur if the invoke call is executed after or while the control is disposing
    168         }
     161        Invoke((Action)UpdateProgressValue);
    169162        return;
    170163      }
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r15415 r15446  
    6161      set {
    6262        if (InvokeRequired) {
    63           Action<string> action = delegate(string s) { this.Title = s; };
     63          Action<string> action = delegate (string s) { this.Title = s; };
    6464          Invoke(action, value);
    6565        } else
     
    7272      set {
    7373        if (InvokeRequired) {
    74           Action<Cursor> action = delegate(Cursor c) { this.Cursor = c; };
     74          Action<Cursor> action = delegate (Cursor c) { this.Cursor = c; };
    7575          Invoke(action, value);
    7676        } else
     
    9595        if (this.activeView != value) {
    9696          if (InvokeRequired) {
    97             Action<IView> action = delegate(IView activeView) { this.ActiveView = activeView; };
     97            Action<IView> action = delegate (IView activeView) { this.ActiveView = activeView; };
    9898            Invoke(action, value);
    9999          } else {
     
    230230    }
    231231
    232     public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent {
     232    public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, IContent {
    233233      if (content == null) throw new ArgumentNullException("Content cannot be null.");
    234234      if (!reuseExistingView) return ShowContent(content);
     
    350350    private readonly List<ProgressView> progressViews = new List<ProgressView>();
    351351
     352    public IProgress AddOperationProgressToContent(IContent content, string progressMessage, double? initialProgressValue = null, bool addToObjectGraphObjects = true) {
     353      var progress = new Progress();
     354      if (initialProgressValue.HasValue)
     355        progress.Start(progressMessage, initialProgressValue.Value);
     356      else
     357        progress.Start(progressMessage);
     358      AddOperationProgressToContent(content, progress, addToObjectGraphObjects);
     359      return progress;
     360    }
    352361    /// <summary>
    353362    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
    354363    /// </summary>
    355     [Obsolete]
    356     public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     364    public void AddOperationProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
    357365      if (InvokeRequired) {
    358         IProgress result = (IProgress)Invoke((Func<IContent, string, bool, IProgress>)AddOperationProgressToContent, content, progressMessage, addToObjectGraphObjects);
    359         return result;
     366        Invoke((Action<IContent, IProgress, bool>)AddOperationProgressToContent, content, progress, addToObjectGraphObjects);
     367        return;
    360368      }
    361369      if (contentProgressLookup.ContainsKey(content))
     
    372380        contentViews = contentViews.Where(v => v.Content == content);
    373381
    374       var progress = new Progress();
    375       progress.Start(progressMessage);
    376382      foreach (var contentView in contentViews) {
    377383        progressViews.Add(new ProgressView(contentView, progress));
     
    379385
    380386      contentProgressLookup[content] = progress;
     387    }
     388
     389    public IProgress AddOperationProgressToView(Control control, string progressMessage, double? initialProgressValue = null) {
     390      var progress = new Progress();
     391      if (initialProgressValue.HasValue)
     392        progress.Start(progressMessage, initialProgressValue.Value);
     393      else
     394        progress.Start(progressMessage);
     395      AddOperationProgressToView(control, progress);
    381396      return progress;
    382397    }
    383 
    384398    /// <summary>
    385399    /// Adds a <see cref="ProgressView"/> to the specified view.
    386400    /// </summary>
    387     [Obsolete]
    388     public IProgress AddOperationProgressToView(Control control, string progressMessage) {
    389       var progress = new Progress();
    390       progress.Start(progressMessage);
    391       AddOperationProgressToView(control, progress);
    392       return progress;
    393     }
    394 
    395401    public void AddOperationProgressToView(Control control, IProgress progress) {
    396402      if (InvokeRequired) {
     
    564570      try {
    565571        ((IActionUserInterfaceItem)item.Tag).Execute();
    566       }
    567       catch (Exception ex) {
     572      } catch (Exception ex) {
    568573        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    569574      }
  • branches/EnhancedProgress/HeuristicLab.MainForm/3.3/Progress.cs

    r15445 r15446  
    101101
    102102    /// <summary>
    103     /// Starts an "undefined" progress in marquee-mode
     103    /// Starts or restarts an "undefined" progress in marquee-mode
    104104    /// </summary>
    105105    public void Start(string message) {
     
    109109    }
    110110    /// <summary>
    111     /// Starts a progress in continuous-mode
     111    /// Starts or restarts a progress in continuous-mode
    112112    /// </summary>
    113113    public void Start(string message, double progressValue) {
  • branches/EnhancedProgress/HeuristicLab.Optimizer/3.3/StartPage.cs

    r15235 r15446  
    8888
    8989    private void LoadSamples(object state) {
    90       progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...");
     90      progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...", 0);
    9191      try {
    9292        var assembly = Assembly.GetExecutingAssembly();
     
    138138        };
    139139      groupLookup[standardProblemsGroup] = standardProblems;
    140       var dataAnalysisProblems = new List<string> { "ALPSGP_SymReg", "SGP_SymbClass", "SGP_SymbReg","OSGP_SymReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR" };
     140      var dataAnalysisProblems = new List<string> { "ALPSGP_SymReg", "SGP_SymbClass", "SGP_SymbReg", "OSGP_SymReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR" };
    141141      groupLookup[dataAnalysisGroup] = dataAnalysisProblems;
    142142      var scripts = new List<string> { "GA_QAP_Script", "GUI_Automation_Script", "OSGA_Rastrigin_Script",
  • branches/EnhancedProgress/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionInstanceProviderView.cs

    r15372 r15446  
    5252          try {
    5353            var progress = mainForm.AddOperationProgressToContent(activeView.Content,
    54               "Loading problem instance.");
     54              "Loading problem instance.", 0);
    5555
    5656            Content.ProgressChanged +=
Note: See TracChangeset for help on using the changeset viewer.