Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

The difference between Task.Delay and Device.StartTimer at short delay (timer tick) intervals.

$
0
0

I'm developing a plotting application which needs to plot a physiological signal at 300 Hz. I have elected to draw 12 data points every 40 mSec. using the 'FastLineSeries' of the 'Syncfusion' charting component.

If I use a timer method of the form:

Device.StartTimer(new TimeSpan(0, 0, 0, 0, PLOTFREQUENCY), () => { return PlotData();});

where:

PLOTFREQUENCY = 40 and

PlotData looks something like:

private bool PlotData()
{
plot 12 data points in here....
return true
}

It works perfectly.

However, if I use a construct of the form:

PlotDataAsync();

where:

PlotDataAsync looks something like:

private async void PlotDataAsync()
{
while (true)
{
await Task.Delay(PLOTFREQUENCY);
plot 12 data points in here....
}
}

The plotting is executed correctly, but much more slowly (at about half-speed).

I have only tested this on the Android platform (Nexus 10 and Samsung Note 3).

Can anyone suggest what might be happening?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>