timer and serialdevice in uwp app for raspberry pi2

102 Views Asked by At

I'm developing an application for UWP raspberry, I need to read input of a coin selectors via serial port, I followed the example https://github.com/ms-iot/samples/tree/develop/SerialSample / CS, but I can not fit it into a timer that waits for input from the coin selectors

Thanks

1

There are 1 best solutions below

0
On
public MainPage()
{
    var timer = new DispatcherTimer();
    timer.Tick += DispatcherTimerEventHandler;
    timer.Interval = new TimeSpan(0, 0, 0, 1);
    timer.Start();
} 

private void DispatcherTimerEventHandler(object sender, object e)
{
    coin();            
}

private void coin()
{
    //Runs every second.
}