New topic: 

Service application - how to handle the Run method

<http://forums.realsoftware.com/viewtopic.php?t=30580>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       unclepauly           Post subject: Service application - how to 
handle the Run methodPosted: Wed Oct 21, 2009 4:27 am                        
Joined: Fri Oct 16, 2009 1:36 pm
Posts: 5              hello, 

i posted on the 'getting started' forum but didnt have much luck. maybe someone 
here can help ?

im developing a service application on a Mac using the 'Empty Service' project. 
for now, all i want the service to do is create some global variables when the 
service starts, and dispose of these global variables when the service stops. 
the service application has, amongst other things, a Run method and a Stop 
method. i am using the "launchctl start" command (via Terminal) to start my 
service (after doing "launchctl load" to load it) and the "launchctl stop" 
command to stop my service. i assumed that the Run method would be called when 
the service is started and the Stop method would be called when the service is 
stopped - but it seems not.

as i understand it, when the Run method ends, the Stop method is then 
immediately called. i believe it happens this way due to logging i have added. 
when i do the "launchctl load/start" commands to start the service, i can see 
the Run method being hit - and then i can see the Stop method being hit, which 
surely is not right ? so my initial idea to prevent this was to put a while 
loop in the Run method which just calls DoEvents. i thought that this would 
prevent the Run method from ending - which it does - and i also thought that it 
would allow the Stop method to be called when i do the "launchctl stop" command 
- which it does not.

so i guess my first question is - what is the point of the Stop method in the 
service application ? when does the Stop method actually get called ?  i 
believe that the Stop method should be wired up to some event, that is fired 
when the service is stopped using launcctl. but it looks like the only time it 
ever gets called i when the Run method ends.

if this is true, then my second question is - how do i correctly handle the Run 
method ? am i right with my 'while true..DoEvents' loop ? if so, how can this 
loop ever end (ie on what condition) ? 

thank you.   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to