Start Service Module from main

Rusty

Well-Known Member
Licensed User
Longtime User
Is there a way to have a service module be started and "sit idle" until the main "tweaks" it to do it's function.
For example, I created a service module that plays audio. I need the user experience to be fast, but I need the service module to play audio only when the user touches a view.
I can make the service module run every 500 milliseconds looking for audio file(s) to play, but this seems wasteful.
Can the Service module be stimulated to do its functions from within main, but otherwise sit "idle"?
Thanks
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks,
So does this mean repetitively using StartService for the same service does not create multiple instances, it merely "invokes" the service?
Obviously, using this method, I shouldn't use startserviceat from within the service, correct?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Yes, it just activates the instance of the service. There is always only one instance of the service.
You can use StartServiceAt from within the service. I use it to schedule the next service start (after some time). But in your case I think you do not need it.

Once the service has executed everything in Service_Start it is pretty much dead to you and the OS will clean it up if it needs memory.

You can used IsPaused(service) to check if it is already running or not. (Tip courtesy of corwin42!)
 
Upvote 0
Top