title: How to prevent TextBox flickering?
body: <p>I try to prevent TextBox flickering with no success so far.<br>
  The TextBox is multiline readonly.  </p>
  
  <p>This code run a few times per second. The text has about 10k characters.</p>
  
  <pre><code>int ss = txt.SelectionStart;
  int sl = txt.SelectionLength;
  txt.Text = s;
  txt.SelectionStart = ss;
  txt.SelectionLength = sl;
  </code></pre>
  
  <p>Resarching the problem gives me the following possible solutions<br>
  - but none of them worked.</p>
  
  <p>1) LockWindowUpdate</p>
  
  <pre><code>[System.Runtime.InteropServices.DllImport("user32.dll")]
  private static extern bool LockWindowUpdate(IntPtr hWndLock);
  
  //...
  
  LockWindowUpdate(txt.Handle);
  txt.Text = someText;
  LockWindowUpdate(IntPtr.Zero);
  </code></pre>
  
  <p>2) SetStyle</p>
  
  <pre><code>this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  </code></pre>
  
  <p>3) SuspendLayout / ResumeLayout (guess it has nothing to do with paint - but just a try)</p>
  
  <pre><code>txt.SuspendLayout();
  txt.Text = s;
  txt.ResumeLayout();
  </code></pre>