I am painting a control from a buffer. My code for painting is it:

```
    protected override void OnPaint(PaintEventArgs e)
    {
        if (surface != null)
        {
            using (Bitmap Pintar = new Bitmap(e.ClipRectangle.Width, e.ClipRectangle.Height))
            {

                BitmapData bmd = Pintar.LockBits(new Rectangle(0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);

                e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

                int DtX = e.ClipRectangle.X;
                int DtY = e.ClipRectangle.Y;

                Console.WriteLine(DtX + " - " + bmd.Width + " || " + DtY + " - " + bmd.Height);
                unsafe
                {
                    byte* PunteroL = (byte*)bmd.Scan0;
                    byte* PunteroS = (byte*)(surface.Buffer + (DtX * 4 + surface.Width * DtY * 4));

                    for (int Y = 0; Y < bmd.Height; Y++)
                    {
                        byte* PunteroLT = (byte*)(PunteroL + (bmd.Width * Y * 4));
                        byte* PunteroST = (byte*)(PunteroS + (surface.Width * Y * 4));
                        for (int X = 0; X < bmd.Width; X++)
                        {
                            byte* PunteroLS = (byte*)(PunteroLT + (X * 4));
                            byte* PunteroSS = (byte*)(PunteroST + (X * 4));

                                PunteroLS[0] = PunteroSS[0];
                                PunteroLS[1] = PunteroSS[1];
                                PunteroLS[2] = PunteroSS[2];

                        }
                    }
                }

                Pintar.UnlockBits(bmd);
                e.Graphics.DrawImage(Pintar, DtX, DtY, Pintar.Width, Pintar.Height);
            }
        }
    }

```

The problem here is when I resize the window I got an error "Tryng access to protected memory" and this is because of pointers..

I wanna know if there is any way to leave (or block) the OnPaint event while the user is resizing the view..

Thank! =)