Solved

Kylix Daemon. TTimer

Posted on 2003-11-09
5
435 Views
Last Modified: 2008-01-16
I have a kylix daemon application that is basically a udpserver.
I need it to have some functionality like the TTimer component.
It needs to perform a certain action every 5 mins.
Do I make a child process and make it sleep for 5 mins ?
How do I catch the event when it wakes?
Any help is greatly appreciated. A source code example would be fantastic.
Thankyou. I am extremely urgent.
0
Comment
Question by:RickJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 9714232
mmm...have a look at this time loop example....

ftp://ftp.cncware.com/pub/fpc/daemon.pp
0
 
LVL 8

Author Comment

by:RickJ
ID: 9718744
Thankyou for the link Ferruccio68.
I have something similar to this already.
To activate my function every 5 mins are you saying that I should set secs in this example to 5 ?
Is it practical to do this in the main processing loop or should I have some sort of child process within the main loop?

I hope this makes sense.


{ begin processing loop }
   If secs > 0 Then
   Repeat
      If bHup Then Begin
         {$I-}
         Close(fLog);
         IoResult;
         {$I+}
         NewLog;
         bHup := false;
      End;
      {----------------------}
      { Do your daemon stuff }
      GetTime(hr,mn,sc,sc100);
      Append(flog);
      Writeln(flog,'daemon code activated at ',hr:0,':',mn:0,':',sc:0);
      Close(fLog);
      { the following output goes to the bit bucket (/dev/null) }
      Writeln('daemon code activated at ',hr:0,':',mn:0,':',sc:0);
      {----------------------}
      If not bTerm Then
         { wait a while }
         Select(0,nil,nil,nil,secs);
   Until bTerm;
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 9720684
well....what is coded in the example is a loop that writes in a log file....

of course setting the secs value to your preferred it will be performed into that timing...
BTW the result is a kind of sleep until a particular condition or event happens.

--> Is it practical to do this in the main processing loop or should I have some sort of child process within the main loop?

It depends on what your main process have to do: Yes if it must only perform the action every 5 mins, but if you need to perform other actions in addition so the loop process must be performed by a child process ('cause the wait stuff freeze the process for a while)...

 
0
 
LVL 8

Author Comment

by:RickJ
ID: 9735256
Thankyou Ferruccio68.
Sorry for the delay in replying.
How do I start a looping child process from within the main process?
Answer this and the points are yours.
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 9735541
well...usually the child process differs from the parent just for the PID...actually i'm pretty busy so i've no time to write a complete example but you can find a little kylix daemon's tutorial here http://www.pharos-comms.tele2.co.uk/free_downloads/DaemonsPart1.pdf or this C++ example here http://www.devhome.org/c/tutorials/daemon.html...
Also a couple of Kylix example in Borland Code Central (need login by registered user)...
Hope this help

F68 ;-)
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question