[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

not enought timers

Posted on 2002-04-21
7
Medium Priority
?
440 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
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 150 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 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