Solved

Time Critical Apps

Posted on 1999-01-22
4
184 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 120
Delphi inherited method 6 67
Sending files from  idTcpServer Socket to idTcpClient 2 39
Delphi: barcode reading on android platform 1 26
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 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

9 Experts available now in Live!

Get 1:1 Help Now