Solved

not enought timers

Posted on 2002-04-21
7
415 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
7 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:God_Ares
Comment Utility
plz modify sleep(0); to sleep(1);
0
 

Author Comment

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

12 Experts available now in Live!

Get 1:1 Help Now