Community

Firing code block for specific amount of time?

N3wifi
Anyone have suggestions on how to fire a code block for only a certain amount of time after button press interrupt? Not real familiar with Micro Framework, in the past i used to achieve this by adding the timer object and wrapping code to be repeated in the event handler Timer.Tick() and run for the specified Timer.Interval. ie.

Timer TimerDuration =  new Timer();

TimerDuration.interval = 20000;
TimerDuration.Enabled = True;

Want to fire the Handler after a button interrupt port.

Private void TimerDuration_Tick(object sender, EventArgs e)
{
          //My code that i want to run for the specified amount of time!
}

Not sure the best way to implement this in the Micro Framework, or maybe there’s a better way.
Any help is appreciated.

Timers exist in NETMF, check out this post from back in 2013.

Regards,
Mark

That’s what i was looking for, thank you.