Solved

Kylix Daemon. TTimer

Posted on 2003-11-09
5
431 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
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 22

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 22

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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