?
Solved

Time Critical Apps

Posted on 1999-01-22
4
Medium Priority
?
190 Views
Last Modified: 2010-04-06
I am looking for a way to force windows to check an application within a certain period.

This does not need to be particularly fast, say every 20milliseconds, but it must occur every 20ms. I don't want other programs to come along and take over processor time such that it turns into 30ms or anything like that

any ideas... I am fairly new at Delphi but want to investigate this

0
Comment
Question by:jaredc071598
[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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1362775
What you can do is increase the process priority.
Take a look at the API below.
BOOL SetPriorityClass(  HANDLE hProcess,        // handle to the process
  DWORD dwPriorityClass   // priority class value);

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362776
Yes, and SetThreadPriority(GetCurrentThread,...).
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1362777
Madshi, you are right.
The priority of the thread is the combination of the thread priority and the process priority. Note that it is a relative number so if somebody has a higher number you are still not garanteed to receive focus every 20ms.

Usually I search for other solutions. Priorities are dirty. If you need it to access hardware, see if there is a buffer. That is much more useful
0
 

Accepted Solution

by:
Almighty_Phoenix earned 200 total points
ID: 1362778
Use the API !

An Example !

uses mmsystem;

var FID:Integer;                 // Handle of MMTimer

procedure TimeCallback(TimerID, Msg:UINT; dwUser, dw1,dw2:DWORD); pascal;
begin
  // your time critical work
end;

// This initializing the Timer
procedure TForm1.RunTimer;
begin
  FID := timeSetEvent(100,0,@TimeCallback,0,TIME_PERIODIC);
end;
// first (100) is the interval (ms)
// second (0) is the accuracy of timer (0 is max)
// third is your callback procedure (not a method !!!)
// 0 is a optional value
// last can be set TIME_ONESHOT (one event) or TIME_PERIODIC
//                                             (intervals)


// This stop the Timer
procedure TForm1.StopTimer;
begin
  if boolean(FID) then timeKillEvent(FID);
end;







0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 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