[SailfishDevel] Scheduling code for execution at x seconds since epoch
Ove Kåven
ovek at arcticnet.no
Sun Mar 16 15:17:04 UTC 2014
Den 16. mars 2014 14:14, skrev Arvid Fahlström Myrman:
> Yes, I've been playing around with BackgroundJob from nemo-keepalive a little
> since I wrote that. It seems to mostly work similarly to Insomniac, with the
> added benefit of preventing suspend after triggering until BackgroundJob's
> finished() method is called. It's a bit finicky to use though, since it seems to
> always trigger once immediately upon being enabled, and it doesn't have a
> repeat property that can be set to false, so to prevent it from running more
> than once you have to set enabled to true when it's triggered and hope that it
> doesn't have time to schedule the next event
"Set enabled to true"? Do you mean setting it to false? Or how exactly
are you using it? As far as I can tell, you should set enabled to true
to start the timer, and enabled to false to stop it.
You should probably set enabled to false *after* your job is done,
because setting it to false will also do what finished() does.
If the timer were to elapse again before you're done, this would be
ignored as long as you haven't called finished or set enabled to false.
So you shouldn't be getting more than one trigger of this kind (in theory).
To start the timer using a range (instead of just a frequency), set the
minimumWait and maximumWait properties as desired, and the frequency
property to "Range". Then start the timer by setting enabled to true.
(The timer should not be enabled before you've set all these properties,
or you might risk funny effects.)
> Regarding timed, I have looked at nemo-qml-plugin-alarms previously, but from
> what I could tell (though I'll admit I didn't really take the time to actually
> understand how it works, so it's very possible that I wasn't using it
> correctly) it is not really possible to schedule a specified piece of code for
> execution using it;
With the C++ interface it's possible (well, at least it's possible to
start any program or send any D-Bus message). Perhaps the QML interface
is less flexible in that regard...
More information about the Devel
mailing list