Bug? Duplicate calls to Sensor_SensorChanged using PhoneSensors in service

daemon

Active Member
Licensed User
Longtime User
I observe duplicate calls to Sensor_SensorChanged when PhoneSensor is used in a service and StartListening() / StopListening() are called multiple times.

It looks like StopListening() doesn't actually stop listening to sensor events and every call to StartListening() adds another callback, resulting in duplicate events.

Attached code demonstrates the behavior.

Actual output (log window) is:
Event count (Start): 0
Event count (Stop): 10 Diff: 10
Event count (Start): 24
Event count (Stop): 44 Diff: 20
Event count (Start): 82
Event count (Stop): 112 Diff: 30
Event count (Start): 163
Event count (Stop): 203 Diff: 40

Expected output:
Event count (Start): 0
Event count (Stop): 10 Diff: 10
Event count (Start): 10
Event count (Stop): 20 Diff: 10
Event count (Start): 20
Event count (Stop): 30 Diff: 10
Event count (Start): 30
Event count (Stop): 40 Diff: 10
 

Attachments

  • SensorService.zip
    8.1 KB · Views: 345
Top