473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Execution priority

How can a program change its execution priority in the operating system while it is running?

-Harry
Nov 16 '05 #1
4 4195
Hi Harry,

"Harry J. Smith" <hj*****@ix.netcom.com> wrote in message
news:_D****************@newsread2.news.pas.earthli nk.net...
How can a program change its execution priority in the operating system
while it is running?

-Harry


Try tweaking:

System.Threading.Thread.CurrentThread.Priority

and

System.Diagnostics.Process.GetCurrentProcess().Pri orityClass.
--
Lars Wilhelmsen
http://www.sral.org/
Software Engineer
Teleplan A/S, Norway
Nov 16 '05 #2

using System.Threading;
....
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
....

--Richard
"Harry J. Smith" wrote:
How can a program change its execution priority in the operating system while it is running?

-Harry

Nov 16 '05 #3
Thanks!

The following code works and does what I was looking for, but in Windows XP pro that I am using the Windows Task Manager still shows
the Base Priority as Normal. I can tell by looking at CPU percent of utilization that the code is working.

using System.Threading; // for Thread

public static void GetPriority() // display priority status
{
string st = Thread.CurrentThread.Priority.ToString();
Console.WriteLine("Priority is " + st);
}

public static void SetPriority(int p) // change priority to p
{
if (p == 2)
Thread.CurrentThread.Priority = ThreadPriority.Highest;
else if (p == 1)
Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
else if (p == -1)
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
else if (p == -2)
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
else
Thread.CurrentThread.Priority = ThreadPriority.Normal;
GetPriority();
}

-Harry

"Richard" <Ri*****@discussions.microsoft.com> wrote in message news:D0**********************************@microsof t.com...

using System.Threading;
...
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
...

--Richard
"Harry J. Smith" wrote:
How can a program change its execution priority in the operating system while it is running?

-Harry

Nov 16 '05 #4


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
38
by: vashwath | last post by:
Might be off topic but I don't know where to post this question.Hope some body clears my doubt. The coding standard of the project which I am working on say's not to use malloc.When I asked my...
4
by: Vlad | last post by:
I have implemented an asyncrhonous execution of a method using the delegate's BeginInvoke() I am trying to spin multiple worker threads in a thread pool. Here is the code: TestProcess process =...
10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
4
by: Hari | last post by:
From: "Hari" <harixseshadri@yahoo.com> Subject: .exe file execution Date: Friday, August 13, 2004 2:42 PM In VB.NET, the output is a .exe file. Since I am new at VB, I am still only programming...
8
by: Frank van Vugt | last post by:
Hi, If during a transaction a number of deferred triggers are fired, what will be their execution order upon the commit? Will they be executed in order of firing or alfabetically or...
1
by: apondu | last post by:
Hi, This is Govardhan, i am working on C#.Net. I have a problem and i am sure most of them would have come across this problem. I have written a application in C#.Net. It does lot of work...
0
by: Virat Sarswat | last post by:
was trying to suspend and resume the inprocess function calls using .Net threading but didn't get success. for making it more clear below is the code i used Thread ThreadSuspend = new...
6
by: Mikhail Kovalev | last post by:
I'm using set_time_limit() to set maximum execution time. Is there a way to check how much time is left at any time during the execution itself?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.