title: Draw rotating lines in pictureBox
body: <p>I want to draw a rotating animation of a line inside a <code>PictureBox</code>. I use <code>pictureBox1.CreateGraphics()</code> to draw the line but I heard that this method is not suitable for <code>PictureBox</code>. Also, I'm experiencing heavy flickering on the <code>PictureBox</code> windows, any suggestion? Here is a code segment:</p>
  
  <pre><code>    private void OnTimedEvent(object source, PaintEventArgs e)
      {
          try
          {
              if (comport.BytesToRead &gt; 0)
              {
                  X = comport.ReadByte();
                  Y = comport.ReadByte();
                  Z = comport.ReadByte();
              }
  
              Graphics g = pictureBox1.CreateGraphics();
              Pen red = new Pen(Color.Red, 2);
              g.TranslateTransform(100, 80 - X);
              g.RotateTransform(120);
              g.DrawLine(red, new Point(100, 0 + X), new Point(100, 80 - X));
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  
      private void timer1_Tick(object sender, EventArgs e)
      {
          try
          {
              timer1.Interval = 1;
              pictureBox1.Invalidate();
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  </code></pre>