not enought timers

i have a server application which creates a (1) timer for every connection by a client...sometimes due to reasons i still haven't figured out a "not enough timer" message pops up whenever network probs when the network was cut or heavy...has anyone encountered this? thanks a lot! also, my server is a database server accessing SQL server so the load is kind of heavy when there are lots of clients connecting all at the same time to download data from the database

thanks in advance!

Who is Participating?
This should work well enough.

unit Timer;


Uses classes,windows;


TProc = Procedure(Sender : TObject) of object;

TProcTimer = record
                fInterval : LongWord;
                fStartClock : LongWord;
                fActive : Boolean;
                fProc : TProc;

TProcTimers = array of TProcTimer;

TThreadTimer = Class(TThread)
                 FTimerData : TProcTimers;
                 FCaling : Integer;
                 Procedure Execute ; override;
                 Procedure ProcedureCaller;
                 Function Add(Proc : TProc; interval : LongWord) : Boolean;
                 Constructor Create;


Constructor TThreadTimer.Create;
  inherited Create(false);

Procedure TThreadTimer.Execute;
Var i:Integer;
Var StopTime,t : Longint;

  While Not Terminated Do
    StopTime := GetTickCount;
    For i:=0 to Length(FTimerData)-1 Do
      FCaling := i;
      If ftimerdata[i].fActive then
        t := (StopTime-ftimerdata[i].fStartClock);
        if (t >= ftimerdata[i].fInterval) then Synchronize(ProcedureCaller);
    Sleep(0);  //give procesor to other process.

Procedure TThreadTimer.ProcedureCaller;
var Call : Tproc;
  call := Ftimerdata[fcaling].fProc;
  Ftimerdata[fcaling].fStartClock := GetTickCount;

Function TThreadTimer.Add(Proc : TProc; interval : LongWord) : Boolean;
var b:Boolean;
  b:= 1=0;
    SetLength(FTimerData,Length(FTimerData)+1); //increase size.
    With FTimerData[Length(FTimerData)-1] Do
      fInterval := interval;
      fProc := Proc;
      fActive := 1=1;
      fStartClock := GetTickCount;
    b := 1=1;
  result := b;

There is a maximum number of timers that can be created. Therefore if you are really in need of a lot of timers, check out the RX Components, they have an RxTimerList component which can address your current problem.
try avoiding timers and use GetTickCount instead.

make a startclock, stopclock mechanism..


startclock := getTickCount;
timer := 900;

while not (stopclock-startclock>=timer) do
  stopclock := getTickCount;

of course you want to have some sort of the timer's way of usage.. i'll make one if you want... i would design it so you have a Ttimer and it has a add(proc : Tporoc; interval : longint);
tProp = procedure(Sender:TObject);

and some other functions as remove_proc alter interval etc.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

plz modify sleep(0); to sleep(1);
dabestprogrammerindauniverseAuthor Commented:
whoa...god_ares that's kinda heavy stuff for me...can you please explain the code that you just did? sorry...

well i create a new thread, and i hang in call's with will be called if their due..

it's kinda quick but im in a hurry just ask me what you want to know
This question is reasonably current but needs your response.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
POINTS FOR EXPERTS awaiting comments are listed in the link below
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.