Solved

Time Critical Apps

Posted on 1999-01-22
4
179 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
Comment Utility
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
Comment Utility
Yes, and SetThreadPriority(GetCurrentThread,...).
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Save pdf file to other location 3 72
Simple Delphi Question 9 77
FMX StringGrid1->Canvas->FillRect Problem 3 98
LAN or WAN ? 11 58
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

17 Experts available now in Live!

Get 1:1 Help Now