Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:47:28+00:00 2026-05-25T12:47:28+00:00

After I google so much and I still cant understand how does the delegate

  • 0

After I google so much and I still cant understand how does the delegate and event works.

What I want to achieve is:
Class 1 will be playing animation, when the animation END, it will pass the delegate/event to the Class 2 so that Class 2 will do something on the animation END.

I wonder how can I code the above behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:47:28+00:00Added an answer on May 25, 2026 at 12:47 pm

    Very basic event implementation…

    public delegate void Class1AnimationCompletedHandler(object sender, EventArgs e);
    
    public class Class1
    {
        public event Class1AnimationCompletedHandler AnimationCompleted;
    
        private void OnAnimationCompleted(EventArgs e)
        {
            if (this.AnimationCompleted != null)
            {
                // raises the AnimationCompleted event
                this.AnimationCompleted(this, e);
            }
        }
    
        public void Animate()
        {
            // do your animation steps here
    
            this.OnAnimationCompleted(new EventArgs());
        }
    }
    
    public class Class2
    {
        private Class1 c1;
    
        public Class2()
        {
            // initialize the class
            c1 = new Class1();
    
            // attach this.Class1_AnimationCompleted to the AnimationCompleted event;
            c1.AnimationCompleted += new Class1AnimationCompletedHandler(this.Class1_AnimationCompleted);
        }
    
        private void Class1_AnimationCompleted(object sender, EventArgs e)
        {
            // do your post-animation stuff here
        }
    
    }
    

    This link provides a good quick example on how to create events. It’s targeted for VS 2003, but is still applicable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading google, I still don't quite understand what this does/means? Could someone explain
I want my program always know all of the mountpoints. After a quick google
Ordinarily I wouldn't just post an error message on SO, but after a Google
After test driving Google Chrome for 30 minutes or so, I like it, even
After a quick Google I couldn’t find anything too promising so I was wondering
After I downloaded the Google Mail and Google Maps application into my mobile phone
after launching your app on google app engine. you can use the 'logs' page
After looking a while other google, and the web, I decided to post my
After trying to setup my site for Google Webmaster Tools I found that my
After being stumped by an earlier quesiton: SO google-analytics-domain-data-without-filtering I've been experimenting with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.