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#
tutorialcsharpquestion
4 Posts 4 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
    deanoA
    wrote on last edited by
    #1

    Hey, I am creating an alarm clock in c#. I want to create a event that calls a method to , lets say tell the user what time it is. I tried to read all tutorials on events and delegates. Still, I have no idea how to implement things. can anybody show me a very simple example? "To teach is to learn twice"

    J M I 3 Replies Last reply
    0
    • D deanoA

      Hey, I am creating an alarm clock in c#. I want to create a event that calls a method to , lets say tell the user what time it is. I tried to read all tutorials on events and delegates. Still, I have no idea how to implement things. can anybody show me a very simple example? "To teach is to learn twice"

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      public delegate void TimerEventHandler(object sender, TimerEventArgs e);
       
      public class TimerEventArgs : EventArgs
      {
      //TODO: put in property procedures here for each event argument
      }
       
       
      //---in the class that raises an event---
      public event TimerEventHandler TimerRing;
      protected OnTimerRing(TimerEventArgs e)
      {
      if(TimerRing!=null) TimerRing(this,e);
      }
       
       
      //---in the class that consumes the event---
      private void TimerRung(object sender, TimerEventArgs e)
      {
      //handle the event here
      }
       
       
      //---in the method that hooks up the event---
      AlarmClock.TimerRing+=new TimerEventHandler(this.TimerRung);

      "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
      "You must be the change you wish to see in the world." - Mahatma Gandhi

      1 Reply Last reply
      0
      • D deanoA

        Hey, I am creating an alarm clock in c#. I want to create a event that calls a method to , lets say tell the user what time it is. I tried to read all tutorials on events and delegates. Still, I have no idea how to implement things. can anybody show me a very simple example? "To teach is to learn twice"

        M Offline
        M Offline
        Meysam Mahfouzi
        wrote on last edited by
        #3

        I will submit a complete tutorial in next 1 or 2 days. I will completely clarify them from scratch. So, hold on just 1 or 2 days Thanx


        Don't forget, that's

        Persian Gulf

        not Arabian gulf!

        1 Reply Last reply
        0
        • D deanoA

          Hey, I am creating an alarm clock in c#. I want to create a event that calls a method to , lets say tell the user what time it is. I tried to read all tutorials on events and delegates. Still, I have no idea how to implement things. can anybody show me a very simple example? "To teach is to learn twice"

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          Go to help search in your .net IDE and search for "AlarmClock". Microsoft created a tutorial on it. nick I'm not an expert yet, but I play one at work. Yeah and here too.

          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