Solved

Kylix Daemon. TTimer

Posted on 2003-11-09
5
429 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
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
mmm...have a look at this time loop example....

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

Author Comment

by:RickJ
Comment Utility
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 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
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
Comment Utility
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 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now