Fix logic error in periodic task wait code.

I was calculating the time to wait for the next run of a periodic
task incorrectly.

Resolves bug 1098819.

Change-Id: Ida60b69014aa06229111e58024e35268262f18fb
Merge "Fix logic error in periodic task wait code."