//----------------------- //TwoPaintHandlers.cs一个窗口,两个paint方法 //------------------------- using System; using System.Windows.Forms; using System.Drawing; using System.Threading; class TwoPaintHandlers { public static void Main() { Form form =new Form(); form.Text ="Two Paint Handlers"; form.BackColor =Color.White; form.Paint +=new PaintEventHandler(PaintHandler1); form.Paint +=new PaintEventHandler(PaintHandler2); Application.Run(form); } static void PaintHandler1(object objSender,PaintEventArgs pea) { Form form=(Form)objSender; Graphics grfx=pea.Graphics; grfx.DrawString("First Paint Event Handler",form.Font,Brushes.Black,0,0); } static void PaintHandler2(object objSender,PaintEventArgs pea) { Thread.Sleep(2500); Form form=(Form)objSender; Graphics grfx=pea.Graphics; grfx.DrawString("Second Paint Event Handler",form.Font,Brushes.Black,0,100); } }
想象中应该先出现First Paint Event Handler 等2.5秒后出现Second Paint Event Handler 但事实不是。为什么。请指教