Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How to modify the process priority of a shelled application with Visual FoxPro
Article ID: 193846 - View products that this article applies to.
This article was previously published under Q193846
A process' priority determines how its execution is scheduled by the Win32 kernel. Processes with a higher priority execute more quickly than processes with a lower priority. This article describes how to modify the Process priority of a shelled application.
Win32 supports the following four priority classes:
Normal priority class is the default, indicating a process with no special scheduling needs.
High priority indicates a process that performs time-critical tasks requiring immediate execution for it to run correctly. The threads of a high-priority class process preempt the threads of normal or idle priority class processes. An example is the Windows Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high- priority class CPU-bound application can use almost all available cycles.
The Realtime priority indicates a process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive. This priority should almost never be used.
The process' priority is set by assigning one of the parameters of the CreateProcess API call.
The following example demonstrates running the Windows NOTEPAD application under Windows NT 4.0 and later Windows operating systems using an idle priority. The process priority is controlled by the 'dwCreationFlags' variable passed to CreateProcess(). DEFINEs for the four supported priority classes are listed at the top of the sample program.
Once Notepad.exe is running, to examine the priority, start the Windows Task Manager, select the Processes tab, right-click Notepad.exe and select 'Set Priority' from the pop-up menu.
The fully qualified pathname to Notepad.exe may need modification in the assignment statement of variable 'File2Run'.
"Advanced Windows", Jeffrey Richter, Microsoft Press, pages 92-103, Third Edition 1997, ISBN: 1-57231-548-2
Article ID: 193846 - Last Review: January 27, 2005 - Revision: 3.4