Post not yet marked as solved
Post marked as unsolved with 2 replies, 321 views
Hi everyone. I'm developing a private app which can extract sensor data in a background timer.
To run a timer in the background, I use a small trick: Enabling location update capability in background mode allows my timer to run backgrounded, and it actually works!
My problem is: I choose 100Hz for my repeating timer fire interval in the background. However, the truth is sampling frequency is fluctuating. I've drawn a graph in my computer and the file is at test1.png - https://github.com/GeniusFKT/iOSSensor/blob/master/TimeIntervalTest/test1.png
As you can see, when app is in the foreground, it works well. Then I switch it to the background, system spends a lot of time (about 1 second) to do the switching. Then when my app is in the background, the frequency starts to fluctuate in [10ms, 100ms] interval. But I hope my timer would run steadily in background too. Then I switch to foreground again, which works perfectly also.
My question is: how can I run a timer steadily in a very big frequency(like 100Hz+)?