-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write multiple timers for one Service. #36
Comments
Its an enhancement that I've been thinking about for a while - allowing multiple timers. I'm afraid that there is a fair amount of work to put into place so unlikely to have any time soon. Couple of ideas to emulate; Option 1; Create a separate Background Service for each timer. You would have separate implementation of BackgroundService.java & .js files. Each service would do it's own work and can have it's own timer. Option 2; Set the timer to run at the fastest frequency you require then have a counter & flag within doWork() to decide to also run the slower frequency work. For the above example, set the timer to run every minute, then within doWork() something like:
Its far from perfect, but may accomplish what you desire. |
Yes, I thought about 2nd option, maybe it's what I will do for a while. |
Why would you say its good practice? (Option 1, more than 1 service) Seems fairly comment to have multiple services on Android (native email app for example shows on my phone as 1 process and 2 services). Plus from a software architecture perspective, it makes sense to separate functionally different operations into different services to keep them isolated and make maintenance easier. Not saying I'm right, just interested in your point of view ;) |
Moved to new repo -> Red-Folder/bgs-core#30 |
Hello,
1st of all thanks for great plugin. From example we have timer (by default 60 sec) that runs
doWork()
in loop every minute and useupdateHandler
. So far so good.What if I want to run additional timer lets say other Thread (on the same service
MyService
) that will rundoWork2()
each 6 min. Is it posible or I need to write my own. Sorry, don't want to reinvent the wheel.Thanks,
The text was updated successfully, but these errors were encountered: