Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4234


Ignore:
Timestamp:
08/16/10 23:56:28 (14 years ago)
Author:
mkommend
Message:

Added InvokeRequired check to ShowContent method (ticket #1154).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForm.cs

    r4201 r4234  
    113113      if (InvokeRequired)
    114114        Invoke((MethodInvoker)OnActiveViewChanged);
    115       else if (ActiveViewChanged != null)
    116         ActiveViewChanged(this, EventArgs.Empty);
     115      else {
     116        EventHandler handler = ActiveViewChanged;
     117        if (handler != null)
     118          handler(this, EventArgs.Empty);
     119      }
    117120    }
    118121
     
    226229
    227230    public IContentView ShowContent(IContent content, Type viewType) {
    228       if (content == null)
    229         throw new ArgumentNullException("Content cannot be null.");
    230       if (viewType == null)
    231         throw new ArgumentNullException("ViewType cannot be null.");
    232 
    233       IContentView view;
    234       if (this.ShowContentInViewHost) {
    235         ViewHost viewHost = new ViewHost();
    236         viewHost.ViewType = viewType;
    237         view = viewHost;
    238       } else
    239         view = MainFormManager.CreateView(viewType);
    240 
    241       view.Content = content;
    242       view.Show();
    243       return view;
     231      if (InvokeRequired) return (IContentView)Invoke((Func<IContent, Type, IContentView>)ShowContent, content, viewType);
     232      else {
     233        if (content == null)
     234          throw new ArgumentNullException("Content cannot be null.");
     235        if (viewType == null)
     236          throw new ArgumentNullException("ViewType cannot be null.");
     237
     238        IContentView view;
     239        if (this.ShowContentInViewHost) {
     240          ViewHost viewHost = new ViewHost();
     241          viewHost.ViewType = viewType;
     242          view = viewHost;
     243        } else
     244          view = MainFormManager.CreateView(viewType);
     245
     246        view.Content = content;
     247        view.Show();
     248        return view;
     249      }
    244250    }
    245251
Note: See TracChangeset for help on using the changeset viewer.