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

  • Home
  • SEARCH
  • 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 235515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:16:16+00:00 2026-05-11T20:16:16+00:00

In a previous SO question it was recommended to me to use callback/event firing

  • 0

In a previous SO question it was recommended to me to use callback/event firing instead of polling. Can someone explain this in a little more detail, perhaps with references to online tutorials that show how this can be done for Java based web apps.

Thanks.

  • 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-11T20:16:16+00:00Added an answer on May 11, 2026 at 8:16 pm

    The definition of a callback from Wikipedia is:

    In computer programming, a callback is
    executable code that is passed as an
    argument to other code. It allows a
    lower-level software layer to call a
    subroutine (or function) defined in a
    higher-level layer.

    In it’s very basic form a callback could be used like this (pseudocode):

    void function Foo()
    {
       MessageBox.Show("Operation Complete");
    }
    
    void function Bar(Method myCallback)
    {
      //Perform some operation
      //When completed execute the callback method
      myCallBack().Invoke();
    }
    
    static int Main()
    {
       Bar(Foo); //Pops a message box when Bar is completed
    }
    

    Modern languages like Java and c# have a standardized way of doing this and they call it events. An event is simply a special type of property added to a class that contains a list of Delegates / Method Pointers / Callbacks (all three of these things are the same thing. When the event gets “fired” it simply iterates through it’s list of callbacks and executes them. These are also referred to as listeners.

    Here’s an example

    public class Button
    {
       public event Clicked;
    
       void override OnMouseUp()
       {
            //User has clicked on the button. Let's notify anyone listening to this event.
           Clicked(); //Iterates through all the callbacks in it's list and calls Invoke();
       }
    }
    
    public class MyForm
    {
       private _Button;
    
       public Constructor()
       {
           _Button = new Button();
    
          //Different languages provide different ways of registering listeners to events.
          // _Button.Clicked += Button_Clicked_Handler;
          // _Button.Clicked.AddListener(Button_Clicked_Handler); 
       }
    
       public void Button_Clicked_Handler()
       {
           MessageBox.Show("Button Was Clicked");
       }
    }
    

    In this example the Button class has an event called Clicked. It allows anyone who wants to be notified when is clicked to register a callback method. In this case the “Button_Clicked_Handler” method would be executed by Clicked event.

    Eventing/Callback architecture is very handy whenever you need to be notified that something has occurred elsewhere in the program and you have no direct knowledge of when or how this happens.

    This greatly simplifies notification. Polling makes it much more difficult because you are responsible for checking every so often whether or not an operation has completed. A simple polling mechanism would be like this:

    static void CheckIfDone()
    {
        while(!Button.IsClicked)
        {
           //Sleep
        }
    
        //Button has been clicked.
    }
    

    The problem is that this particular situation would block your existing thread and have to continue checking until Button.IsClicked is true. The nice thing about eventing architecture is that it is asynchronous and let’s the Acting Item (button) notify the listener when it is completed instead of the listener having to keep checking,

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

Sidebar

Related Questions

On Previous Question , someone recommended that I install Andy's IDE Fix Pack to
In previous question of mine, someone had meantioned that using Semaphores were expensive in
This question is extended part of my previous question, Finding number position in string
This question is based on my previous question which I got a working answer
This question is related to a previous question of mine That's my current code
This question follows on from a previous question, that has raised a further issue.
This question is related to my previous question How to generate Cartesian Coordinate (x,y)
This question is related to my previous question . The storyline: I have an
This question is a continuation of my previous question here zend models architecture (big
This question is in continuation to my previous question . I am trying to

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.