Solved

Real-time timer

Posted on 2001-08-06
7
630 Views
Last Modified: 2010-04-06
I need a better timer than the TTimer component. I know there is no perfect timer under Windows 95, but what the TTimer does is quite unacceptable. (The TTimer gives on a 100 MHz Pentium, with the timer interval set to 1,  about 24 timer events per sec -- instead of 1000! Note that the test application was 'honest', doing nothing else in the OnTimer event handler than incrementing a counter.)

I have had the followings ideas.

1. Modifying the priority of the main thread, with the following code in the OnCreate method of the main form:

  mythread:=GetCurrentThread;
  SetThreadPriority(mythread,THREAD_PRIORITY_TIME_CRITICAL);

It makes ABSOLUTELY no difference.


2. Using the SetTimer API function with callback function instead of message posting. I haven't tried it, because the Win32 help says the following:

"When you specify a TimerProc callback function, the DispatchMessage function simply calls the callback function instead of the window procedure. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER."

So I have the feeling that it won't help me either.


3. Using a driver-level IRQ callback function.

I'm able to handle the IRQ interrupts under Delphi, using an external VxD which can call my Delphi code as callback function when an interrupt arrives, but I don't know whether the timer works with IRQ, and if so, what IRQ should I handle; I'm also not sure that the Windows 95 will share this IRQ with my VxD.


Waiting for ideas and comments,
Adam
0
Comment
Question by:biroadam
7 Comments
 
LVL 3

Accepted Solution

by:
tongalite earned 200 total points
ID: 6354998
Hi,
There are some timer comps about, I have a couple which I downloaded... a multimedia timer and a threaded timer (supposed to be very accurate to within 1 millisecond) that's supposed to do what you require. Untested yet though by me... Can't remember where I downloaded them but if you leave a temp e_mail address I will send them to you if you want.
have fun!
T.
0
 

Author Comment

by:biroadam
ID: 6355106
Hi tongalite!

Sounds pretty good!
My e-mail address is biroadam@softhome.net, I'm waiting for the components.

Best regards,
Adam
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6355168
get this sample from simonet

entitled

How To Create High Precision Timers (Multimedia timers)
This project is aimed towards those that think Delphi's TTimer is not precise enought. The solution for that is to create a much more precise and reliable timer, a multimedia timer. This how-to project will teach you how to work with them and discuss when to use a multimedia timer and when to use a system timer (TTimer).  


http://www.bhnet.com.br/~simonet/archive/mmtimer.zip
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6355428
Hello

  you can find alot types of timers at torry site, and most of them free

http://www.torry.net/timers.htm

0
 

Author Comment

by:biroadam
ID: 6355586
Hi everybody!

The problem is actually very simple, there are two Windows API functions designed especially for realtime (multimedia) applications, called TimeSetEvent and a TimeKillEvent.

These functions work with a callback function rather than windows messages, and so they are quite accurate.

Actually I realised this reading the sample sent by kretzschmar, however the question is locked by tongalite.
Since I guess tongalite's answer is also correct (but I haven't received the components yet), I'll wait for it.

Thanks to everybody,
Adam
0
 
LVL 3

Expert Comment

by:tongalite
ID: 6356687
Sorry guys.... (and gals) Must have hit the proposed answer button when all I intended was to make a comment. I'll try not to let that happen again.

Adam,
The comps have been mailed.... Hope they are of use to you.
T.
0
 

Author Comment

by:biroadam
ID: 6356834
Hi tongalite,

As I was sure, your answer was as well as the others. There was only a TIMING problem...

Thank you again,
Adam
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 62
drawing animated level bar based on numbers 3 88
update joined tables 2 31
Multi-layered image in FireMonkey 9 16
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

21 Experts available now in Live!

Get 1:1 Help Now