Solved

Time Critical Apps

Posted on 1999-01-22
4
186 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
  • 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 100 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
select query - oracle 16 100
Find and Replace Stream with 0s 8 69
How to load 2 images in same column in Delphi 2 57
Breakpoint doesn't stop in my variable 3 30
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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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