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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Events

Events

Scheduled Pinned Locked Moved C#
question
10 Posts 5 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.
  • D Offline
    D Offline
    Darkness84
    wrote on last edited by
    #1

    Can you fire an event inside of an event that is already executing?

    R S 2 Replies Last reply
    0
    • D Darkness84

      Can you fire an event inside of an event that is already executing?

      R Offline
      R Offline
      RepliCrux
      wrote on last edited by
      #2

      Yes you can.

      D 1 Reply Last reply
      0
      • D Darkness84

        Can you fire an event inside of an event that is already executing?

        S Offline
        S Offline
        Sathesh Sakthivel
        wrote on last edited by
        #3

        This is not good approach by firing an event inside the already firing event.

        Regards, Satips.:rose:

        N N 2 Replies Last reply
        0
        • R RepliCrux

          Yes you can.

          D Offline
          D Offline
          Darkness84
          wrote on last edited by
          #4

          Is there anything special you have to do to get this to work because the event inside the executing event is not firing?

          R 1 Reply Last reply
          0
          • D Darkness84

            Is there anything special you have to do to get this to work because the event inside the executing event is not firing?

            R Offline
            R Offline
            RepliCrux
            wrote on last edited by
            #5

            It is possible that you are not firing the event properly, can you pass me the code.

            D 1 Reply Last reply
            0
            • R RepliCrux

              It is possible that you are not firing the event properly, can you pass me the code.

              D Offline
              D Offline
              Darkness84
              wrote on last edited by
              #6

              This is the code: protected void btnNext_Clicked(object sender, EventArgs e) { switch (m_teststage) { case "STEP1": hidMode.Value = "STEP2"; break; case "STEP2": hidMode.Value = "STEP3"; break; } m_teststage = hidMode.Value; FormatPageChange(); } private void FormatPageChange() { if (m_teststage == "STEP2") InitialiseDMRGrid(); if (m_teststage == "STEP3") InitialiseTestGrid(); SetPanelVisibility(); SetButtonVisibility(); SetValidatorsEnabled(); } private void InitialiseDMRGrid() { WebGridHelper m_webgridhelperDMR = new WebGridHelper(wgDMR, "", "ID"); wgDMR.PrepareDataBinding += new DataSourceEventHandler(wgDMR_PrepareDataBinding); wgDMR.InitializeDataSource += new DataSourceEventHandler(wgDMR_InitializeDataSource); m_webgridhelperDMR.SortColumns += new SortColumnsEventHandler(m_webgridhelperDMR_SortColumns); wgDMR.InitializePostBack += new PostBackEventHandler(wgDMR_InitializePostBack); } If I click the Next button the event fires but when it gets to the InitialiseDMRGrid method it goes in but does not fire the events inside.

              R 1 Reply Last reply
              0
              • D Darkness84

                This is the code: protected void btnNext_Clicked(object sender, EventArgs e) { switch (m_teststage) { case "STEP1": hidMode.Value = "STEP2"; break; case "STEP2": hidMode.Value = "STEP3"; break; } m_teststage = hidMode.Value; FormatPageChange(); } private void FormatPageChange() { if (m_teststage == "STEP2") InitialiseDMRGrid(); if (m_teststage == "STEP3") InitialiseTestGrid(); SetPanelVisibility(); SetButtonVisibility(); SetValidatorsEnabled(); } private void InitialiseDMRGrid() { WebGridHelper m_webgridhelperDMR = new WebGridHelper(wgDMR, "", "ID"); wgDMR.PrepareDataBinding += new DataSourceEventHandler(wgDMR_PrepareDataBinding); wgDMR.InitializeDataSource += new DataSourceEventHandler(wgDMR_InitializeDataSource); m_webgridhelperDMR.SortColumns += new SortColumnsEventHandler(m_webgridhelperDMR_SortColumns); wgDMR.InitializePostBack += new PostBackEventHandler(wgDMR_InitializePostBack); } If I click the Next button the event fires but when it gets to the InitialiseDMRGrid method it goes in but does not fire the events inside.

                R Offline
                R Offline
                RepliCrux
                wrote on last edited by
                #7

                I think the problem is: You are "adding" the events on button click and not "firing" them. They will fire when they are suppose to fire. Your code will add the events to, for eg: wgDMR.InitializeDataSource += new DataSourceEventHandler(wgDMR_InitializeDataSource); and when the DataSource in initialised then this event will fire. (I guess you have defined the event handlers somewhere else, because I can't see the event handlers for any of the above events.)

                D 1 Reply Last reply
                0
                • R RepliCrux

                  I think the problem is: You are "adding" the events on button click and not "firing" them. They will fire when they are suppose to fire. Your code will add the events to, for eg: wgDMR.InitializeDataSource += new DataSourceEventHandler(wgDMR_InitializeDataSource); and when the DataSource in initialised then this event will fire. (I guess you have defined the event handlers somewhere else, because I can't see the event handlers for any of the above events.)

                  D Offline
                  D Offline
                  Darkness84
                  wrote on last edited by
                  #8

                  I see what I am doing wrong now. Thanks for your help.

                  1 Reply Last reply
                  0
                  • S Sathesh Sakthivel

                    This is not good approach by firing an event inside the already firing event.

                    Regards, Satips.:rose:

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #9

                    Why not?


                    only two letters away from being an asset

                    1 Reply Last reply
                    0
                    • S Sathesh Sakthivel

                      This is not good approach by firing an event inside the already firing event.

                      Regards, Satips.:rose:

                      N Offline
                      N Offline
                      N a v a n e e t h
                      wrote on last edited by
                      #10

                      Satips wrote:

                      This is not good approach by firing an event inside the already firing event.

                      WHY ?

                      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