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#
  4. Events

Events

Scheduled Pinned Locked Moved C#
databasequestion
4 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
    pokabot
    wrote on last edited by
    #1

    Can i attach multiple functions to an event Handler/listner? If so is there anyway to prioritize their execution? Also what would happen if you trigger an event with no handler attached? ty

    A L 2 Replies Last reply
    0
    • P pokabot

      Can i attach multiple functions to an event Handler/listner? If so is there anyway to prioritize their execution? Also what would happen if you trigger an event with no handler attached? ty

      A Offline
      A Offline
      Anthony Mushrow
      wrote on last edited by
      #2

      If you trigger an event with no handler, then nothing gets done about it. Make a button with no OnClick handler, and nothing happens when the button is clicked. As for multiple functions, yes you can. When you add a handler to an event you use += so just += another function. As for priority, im not sure. I assume that the first function you added will be executed first, but that may not be the case.

      My current favourite word is: Nipple!

      -SK Genius

      1 Reply Last reply
      0
      • P pokabot

        Can i attach multiple functions to an event Handler/listner? If so is there anyway to prioritize their execution? Also what would happen if you trigger an event with no handler attached? ty

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Additionally to what SK Genius already said, why not just create a method that will call all methods in the priority you like to be called without depending on the order in which they were registered? Something like

        someclass.Event += new EventHandler(MyFunc);

        public void MyFunc(...)
        {
        Func1();
        Func2();
        Func3();
        }

        regards

        P 1 Reply Last reply
        0
        • L Lost User

          Additionally to what SK Genius already said, why not just create a method that will call all methods in the priority you like to be called without depending on the order in which they were registered? Something like

          someclass.Event += new EventHandler(MyFunc);

          public void MyFunc(...)
          {
          Func1();
          Func2();
          Func3();
          }

          regards

          P Offline
          P Offline
          pokabot
          wrote on last edited by
          #4

          I will be adding and removing functions throught the program so i will not know what functions are registered @ what time, thats why i wanted to know if there was a priority.

          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