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. Web Development
  3. ASP.NET
  4. how to pass parameters to timer handler in asp.net

how to pass parameters to timer handler in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorial
3 Posts 2 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.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    Hi , iam still newbie in asp.net I have no idea how to pass parameter to event handler in timer this the code that i have got private Timer Alert = null; protected void Page_Load(object sender, EventArgs e) { Alert = new Timer(); Alert.Start(); Alert.Elapsed = new ElapsedEventHandler(Alert_Timer_Elapsed); AlertTimer.Interval = 30000; } private static void AlertTimer_Elapsed(object source, ElapsedEventArgs e) { } i want int alerttimer_elapsed has a string / object variable as parameters but i am confused how to do it. thanks guys

    C 1 Reply Last reply
    0
    • A Arif Liminto

      Hi , iam still newbie in asp.net I have no idea how to pass parameter to event handler in timer this the code that i have got private Timer Alert = null; protected void Page_Load(object sender, EventArgs e) { Alert = new Timer(); Alert.Start(); Alert.Elapsed = new ElapsedEventHandler(Alert_Timer_Elapsed); AlertTimer.Interval = 30000; } private static void AlertTimer_Elapsed(object source, ElapsedEventArgs e) { } i want int alerttimer_elapsed has a string / object variable as parameters but i am confused how to do it. thanks guys

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      arifliminto86 wrote:

      i want int alerttimer_elapsed has a string / object variable as parameters but i am confused how to do it.

      You don't. The method has all the parameters it is ever going to have - otherwise the signature of the method wouldn't look like Timer.Elapsed event handler. Also, where would you set the string value from? Store it as a field on the class and the event handler can pick it up (once you remove the static on the method)

      Man who stand on hill with mouth open wait long time for roast duck to drop in

      A 1 Reply Last reply
      0
      • C Colin Angus Mackay

        arifliminto86 wrote:

        i want int alerttimer_elapsed has a string / object variable as parameters but i am confused how to do it.

        You don't. The method has all the parameters it is ever going to have - otherwise the signature of the method wouldn't look like Timer.Elapsed event handler. Also, where would you set the string value from? Store it as a field on the class and the event handler can pick it up (once you remove the static on the method)

        Man who stand on hill with mouth open wait long time for roast duck to drop in

        A Offline
        A Offline
        Arif Liminto
        wrote on last edited by
        #3

        thank so much

        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