title: Timer class and calling methods with passing parameter
body: <p>I have a method that uses Timer class to call on a method and execute it on specific intervals. </p>
  
  <pre><code>private Timer tmr = new Timer();
       public void WorkAtInterval(long interval, Action&lt;object&gt; work)
                  {
                      //heartbeat in miliseconds
                      tmr.Interval = interval;
                      tmr.Start();
                      tmr.Elapsed += new ElapsedEventHandler(work);
                  }
  </code></pre>
  
  <p>I have defined the function that has to be called like this:</p>
  
  <pre><code>private static void WorkSample (object interval)
          {
              Console.WriteLine("The interval is: {0}",interval);
          }
  </code></pre>
  
  <p>and then eventually in my Main function:</p>
  
  <pre><code>static void Main(string[] args)
          {
              HeartBeat heart = new HeartBeat();
  
              var interval = heart.HeartBeatInterval;
  
              heart.WorkAtInterval(interval,sampleWork(interval));
  
              Console.Read();
          }
  </code></pre>
  
  <p>unfortunately, this even is not compiling. I am not that great with delegates.Any recommendation on how I can get this to work?</p>