using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using System.ComponentModel;
namespace timerer
{
public class timercomp:Component
{
public int count=0;
System.Timers.Timer myTimer = new System.Timers.Timer();
public timercomp(IContainer container)
{
container.Add(this);
myTimer.Elapsed += new ElapsedEventHandler(OnTimer);
}
public int start()
{
myTimer.Enabled = true;
myTimer.Interval += 1000;
myTimer.AutoReset = true;
return count;
}
public void OnTimer(Object source, ElapsedEventArgs e)
{
myTimer.Enabled = false;
myTimer.Interval += 1000;
count = count + 1;
start();
}
}
}
timercomp comp = new timercomp();
timercomp.start();
don't know why you return count in start, when it is called outside the code above it will always return 0. You should see it incrementing using the debugger though.
Note your intervals are getting bigger and bigger, don't know if that was your intention.