Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. When use callback function?

When use callback function?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    phieu
    wrote on last edited by
    #1

    Hello all, When use callback function, and what is the purpose? Which cases we should use the callback functions? Could you tell me about? Thanks!

    M S 2 Replies Last reply
    0
    • P phieu

      Hello all, When use callback function, and what is the purpose? Which cases we should use the callback functions? Could you tell me about? Thanks!

      M Offline
      M Offline
      munawar1968
      wrote on last edited by
      #2

      http://www.google.co.in/search?q=callback+function

      1 Reply Last reply
      0
      • P phieu

        Hello all, When use callback function, and what is the purpose? Which cases we should use the callback functions? Could you tell me about? Thanks!

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        Callbacks are typically used when the function needs to notify its caller for some reason. This can be for simply informing the caller or for getting information necessary for the function to continue execution. For example, you can have a timer function that runs in a loop and needs to notify someone whenever a timer expires. You'd write something like

        void TimerFunc(CallbackFunc *func)
        {
        while (1)
        {
        // Wait for specified time
        ...
        func();
        }
        }

        They can also be used to alter the function's flow depending on the caller. For example

        void SomeFunc(CallbackFunc* func)
        {
        int x = ...; // Some runtime parameter
        if (func(x) == true)
        {
        // Do this
        }
        }

        As you can see, func gets the ability to change SomeFunc's control flow. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups