473,569 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execution priority

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

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

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

-Harry


Try tweaking:

System.Threadin g.Thread.Curren tThread.Priorit y

and

System.Diagnost ics.Process.Get CurrentProcess( ).PriorityClass .
--
Lars Wilhelmsen
http://www.sral.org/
Software Engineer
Teleplan A/S, Norway
Nov 16 '05 #2

using System.Threadin g;
....
Thread.CurrentT hread.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.Threadin g; // for Thread

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

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

-Harry

"Richard" <Ri*****@discus sions.microsoft .com> wrote in message news:D0******** *************** ***********@mic rosoft.com...

using System.Threadin g;
...
Thread.CurrentT hread.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
12565
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 about whether we should allow polymorphism. Our system is not embedded and does not need to be as real-time as, say, a pacemaker. But it does involve...
38
2529
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 lead(I have just started working) he said we should not use dynamic allocation in real time systems, the code will not run in predictable time...
4
3852
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 = new TestProcess(TestProcess); process.BeginInvoke(args,null,null); private void TestProcess(args) {
10
6854
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 time can take 2-3 minutes, but even though I have set the executionTimeout in web.config to a high number of seconds (2400), the request will still...
4
1759
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 console applications. For a console applications, the only two ways I know of of executing it are to go to command prompt and type in: testrun.exe...
8
2607
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 something entirely different? The docs only mention regular triggers being executed alfabetically.
1
2974
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 so i know
0
815
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 Thread(new ThreadStart(CheckMapVersionEx)); private void button2_Click(object sender, EventArgs e) { ...
6
4532
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?
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.