[Mono-winforms-list] invalidate

Jackson Harper jackson at ximian.com
Wed May 31 02:53:04 EDT 2006


On Tue, 2006-05-30 at 17:18 -0600, Peter Dennis Bartok wrote:
> I haven't tried the code, but I wanted to point out that invaliding inside a 
> paint handler is almost never a good idea 

This actually doesn't seem to work at all with our paint handler on X11
I assume because we end the paint event and clear the invalid area after
the OnPaint so the Invalidate call gets thrown away.  

Not sure if calling Invalidate in a paint handler is a corner case we
need to consider though, I think it will do bad things on windows too
(but can't test right now).

Jackson


> (even when it is asynchronoys). 
> And sleeping in a paint handler is even worse. You're blocking the event 
> queue and preventing your drawing from being completed. If your form were 
> double-buffered, for example, the sleep in the thread would block the buffer 
> from being copied to the screen, even on Windows. You're also keeping any 
> device contexts associated with the paint locked for that amount of time.
> 
>  If you want a regular update on screen, create a System.Windows.Forms.Timer 
> and do the invalidate whenever the timer fires.
> 
> Peter
> 
> -----Original Message-----
> From: "Santi Serrano" <santi.serrano at bigfoot.com>
> To: "Mono WinForms" <mono-winforms-list at lists.ximian.com>
> Date: Tuesday, 30 May, 2006 17:10
> Subject: [Mono-winforms-list] invalidate
> 
> 
> >Hi,
> >
> >The following code draws a line with Mono on Windows but doesn't do
> >anything on Linux. I'm using Monoppix with Mono 1.1.8. Can anyone tell
> >me if this issue is solved with recent releases?
> >
> >Thank you.
> >
> >------------------------------------------------------
> >using System;
> >using System.Drawing;
> >using System.Windows.Forms;
> >using System.Threading;
> >
> >namespace WindowsApplication1
> >{
> > public class Form1 : System.Windows.Forms.Form
> > {
> > private int i;
> >
> > [STAThread]
> > static void Main()
> > {
> > Application.Run(new Form1());
> > }
> >
> > protected override void OnPaint(PaintEventArgs pea)
> > {
> > pea.Graphics.DrawLine(new System.Drawing.Pen(Color.Blue), 1, 1, i, i);
> > Thread.Sleep(200);
> > i++;
> > Invalidate();
> > }
> > }
> >}
> >------------------------------------------------------
> >_______________________________________________
> >Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> >http://lists.ximian.com/mailman/listinfo/mono-winforms-list
> >
> > 
> 
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list



More information about the Mono-winforms-list mailing list