hy guys i have a problem with my event

 public delegate void paintEventHandler(object sender, EventArgs e);
 Graphics paper;
        public static event PaintEventHandler After1s;


        private void Mouth_shut(Graphics gr)
        {
            gr.FillEllipse(new SolidBrush(Color.Yellow), 50, 50, 50, 50);
        }

        private void Mouth_Open(Graphics gr)
        {
            gr.FillPie(new SolidBrush(Color.Yellow), 50, 50, 50, 50, -30, 270);
        }

        private void timer1_Tick(object sender, EventArgs e)// occurs every second
        {

            After1s += new PaintEventHandler(Form1_After1s);
           // after every passed second going to Form1_Paint, INVOKE doesnt work
        }

        void Form1_After1s(object sender, PaintEventArgs e)
        {
            paper = e.Graphics;
            Mouth_Open(paper);
            Thread.Sleep(500);
            Mouth_shut(paper);
        }

I cant get my object to morph , nothing happens. I tried to invoke it but it get some errors, any advice would be apreciated.

Yes, and the problem is?

i dont know how to invoke the event ,

This would normally be something like this:

if(After1st != null)
{
     After1st(this, new MyEventArgs());
}

You aren't invoking, you're just adding an event handler.

You can call the method directly from the Tick event:

if(this.InvokeRequired)
    this.Invoke(new paintEventHandler(Form1_After1s), new { sender, e });
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.