Solved

not enought timers

Posted on 2002-04-21
7
430 Views
Last Modified: 2007-11-27
hi!
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 arise...like 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!

Raymond
0
Comment
[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
7 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6958976
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.

http://www.oxygensoftware.com/download/rx275d6.zip
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 6959158
try avoiding timers and use GetTickCount instead.

make a startclock, stopclock mechanism..

E.G.

startclock := getTickCount;
timer := 900;

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

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.
0
 
LVL 7

Accepted Solution

by:
God_Ares earned 50 total points
ID: 6959367
This should work well enough.



unit Timer;

interface

Uses classes,windows;

Type

TProc = Procedure(Sender : TObject) of object;

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

TProcTimers = array of TProcTimer;

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


implementation

Constructor TThreadTimer.Create;
Begin
  inherited Create(false);
End;

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

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

Procedure TThreadTimer.ProcedureCaller;
var Call : Tproc;
Begin
  call := Ftimerdata[fcaling].fProc;
  call(self);
  Ftimerdata[fcaling].fStartClock := GetTickCount;
End;

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


end.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:God_Ares
ID: 6959470
plz modify sleep(0); to sleep(1);
0
 

Author Comment

by:dabestprogrammerindauniverse
ID: 6968001
whoa...god_ares that's kinda heavy stuff for me...can you please explain the code that you just did? sorry...

0
 
LVL 7

Expert Comment

by:God_Ares
ID: 6970963
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
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6975929
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.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

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.
http://www.experts-exchange.com/questions/Q.20275584.html
http://www.experts-exchange.com/questions/Q.20289499.html
http://www.experts-exchange.com/questions/Q.20289497.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20292076.html

*****  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
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
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.
Moondancer
Moderator @ Experts Exchange
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
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 …

696 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