Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3398 for trunk/sources


Ignore:
Timestamp:
04/18/10 04:33:20 (15 years ago)
Author:
mkommend
Message:

fixed cross threading issues in ViewHost (ticket #972)

Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2
Files:
6 edited

Legend:

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

    r3177 r3398  
    3232
    3333    public static void SuspendRepaint(this Control control) {
    34       SendMessage(control.Handle, WM_SETREDRAW, false, 0);
     34      if (control.InvokeRequired)
     35        control.Invoke((Action<Control>)((c) => { c.SuspendRepaint(); }));
     36      else
     37        SendMessage(control.Handle, WM_SETREDRAW, false, 0);
    3538    }
    3639    public static void ResumeRepaint(this Control control, bool refresh) {
    37       SendMessage(control.Handle, WM_SETREDRAW, true, 0);
    38       if (refresh) control.Refresh();
     40      if (control.InvokeRequired)
     41        control.Invoke((Action<Control, bool>)((c, b) => { c.ResumeRepaint(b); }));
     42      else {
     43        SendMessage(control.Handle, WM_SETREDRAW, true, 0);
     44        if (refresh) control.Refresh();
     45      }
    3946    }
    4047  }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/DockingMainForm.cs

    r3395 r3398  
    7070      IContentView contentView = view as IContentView;
    7171      if (ShowViewsInViewHost && contentView != null && contentView.GetType() != typeof(ViewHost)) {
    72         ViewHost viewHost = new ViewHost(contentView.Content);
     72        ViewHost viewHost = new ViewHost(contentView);
    7373        form = new DockForm(viewHost);
    7474      } else
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.cs

    r3395 r3398  
    7676      IContentView contentView = view as IContentView;
    7777      if (ShowViewsInViewHost && contentView != null && contentView.GetType() != typeof(ViewHost)) {
    78         ViewHost viewHost = new ViewHost(contentView.Content);
     78        ViewHost viewHost = new ViewHost(contentView);
    7979        form = new DocumentForm(viewHost);
    8080      } else
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/SingleDocumentMainForm.cs

    r3395 r3398  
    7070      IContentView contentView = view as IContentView;
    7171      if (ShowViewsInViewHost && contentView != null && contentView.GetType() != typeof(ViewHost)) {
    72         ViewHost viewHost = new ViewHost(contentView.Content);
     72        ViewHost viewHost = new ViewHost(contentView);
    7373        form = new DocumentForm(viewHost);
    7474      } else
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.cs

    r3354 r3398  
    5858    public virtual bool ReadOnly {
    5959      get { return this.readOnly; }
    60        set {
     60      set {
    6161        if (InvokeRequired) {
    6262          Action<bool> action = delegate(bool b) { this.ReadOnly = b; };
     
    208208
    209209    public void SuspendRepaint() {
    210       ((Control)this).SuspendRepaint();
     210      if (InvokeRequired)
     211        Invoke((MethodInvoker)SuspendRepaint);
     212      else
     213        ((Control)this).SuspendRepaint();
    211214    }
    212215    public void ResumeRepaint(bool refresh) {
     216      if (InvokeRequired)
     217        Invoke((Action<bool>)ResumeRepaint,refresh);
     218      else
    213219      ((Control)this).ResumeRepaint(refresh);
    214220    }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewHost.cs

    r3394 r3398  
    2828namespace HeuristicLab.MainForm.WindowsForms {
    2929  [Content(typeof(object))]
    30   public sealed partial class ViewHost : ContentView {
     30  public sealed partial class ViewHost : AsynchronousContentView {
    3131    private Dictionary<Type, IContentView> cachedViews;
    3232    public ViewHost() {
     
    4141      : this() {
    4242      this.Content = content;
     43    }
     44
     45    public ViewHost(IContentView contentView) :this(){
     46      this.viewType = contentView.GetType();
     47      this.Content = contentView.Content;
     48      this.cachedViews.Add(contentView.GetType(), contentView);
     49      this.UpdateView();
    4350    }
    4451
     
    8895      viewsLabel.Visible = false;
    8996      viewPanel.Visible = false;
    90       if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose();
    91       viewPanel.Controls.Clear();
    9297
    9398      if (Content != null) {
Note: See TracChangeset for help on using the changeset viewer.