Changing thread priority when thread is running

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

If I change the thread priority when the thread is running, will this have any effect (ie will thread priority effectively be changed)

Thread wThread = ...
// ..
wThread.Start()

// ..
wTread.Priority = ThreadPriority.AboveNormal

Thanks
Tom Tempelaere.
 
Tom,

Setting it in itself should have no ill effect. However, if your
application has timing requirements with other apps, then this could have an
effect. Also, if you are going to increase the thread priority, I would
recommend not doing so. Personally, I think it is bad forum when an app
declares to the OS that it is more important than anything else running.
Generally speaking, if you are having performance issues, then this is not
the way to go about it.

Of course, if you are lowering your thread priority, then this doesn't
apply. =)

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


TT (Tom Tempelaere) said:
Hi,

If I change the thread priority when the thread is running, will this have
any effect (ie will thread priority effectively be changed)?
 
Hi Nicholas,

The context requires some parts to be real-time. I could break it up in
multiple threads, but in this case it doesn't seem natural because the work
on the thread is sequential. Another fact is that I'm sort of embedded.
There are only two major processes running, mine & another. When I have to
do the real-time parts, I know that the other process is not doing anything
that requires responsiveness. _And_, I'm aware of priority issues ;-)

Apart from that, I'm making a thread base class. It provides some plumbing
stuff, for instance changing the thread priority (which is just forwarding
to Thread.Priority). I read the documentation but I didn't find an answer to
my question. That's why I posted it.

Thanks,
---
Tom Tempelaere


Nicholas Paldino said:
Tom,

Setting it in itself should have no ill effect. However, if your
application has timing requirements with other apps, then this could have an
effect. Also, if you are going to increase the thread priority, I would
recommend not doing so. Personally, I think it is bad forum when an app
declares to the OS that it is more important than anything else running.
Generally speaking, if you are having performance issues, then this is not
the way to go about it.

Of course, if you are lowering your thread priority, then this doesn't
apply. =)

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


TT (Tom Tempelaere) said:
Hi,

If I change the thread priority when the thread is running, will this
have
any effect (ie will thread priority effectively be changed)?
Thread wThread = ...;
// ...
wThread.Start();

// ...
wTread.Priority = ThreadPriority.AboveNormal;

Thanks,
Tom Tempelaere.
 
Nicholas,

Do note that I am not coding yet, so I might as well end up with a totally
different sheme.

:-))
---
Tom Tempelaere


TT (Tom Tempelaere) said:
Hi Nicholas,

The context requires some parts to be real-time. I could break it up in
multiple threads, but in this case it doesn't seem natural because the work
on the thread is sequential. Another fact is that I'm sort of embedded.
There are only two major processes running, mine & another. When I have to
do the real-time parts, I know that the other process is not doing anything
that requires responsiveness. _And_, I'm aware of priority issues ;-)

Apart from that, I'm making a thread base class. It provides some plumbing
stuff, for instance changing the thread priority (which is just forwarding
to Thread.Priority). I read the documentation but I didn't find an answer to
my question. That's why I posted it.

Thanks,
---
Tom Tempelaere


message news:[email protected]...
Tom,

Setting it in itself should have no ill effect. However, if your
application has timing requirements with other apps, then this could
have
an
effect. Also, if you are going to increase the thread priority, I would
recommend not doing so. Personally, I think it is bad forum when an app
declares to the OS that it is more important than anything else running.
Generally speaking, if you are having performance issues, then this is not
the way to go about it.

Of course, if you are lowering your thread priority, then this doesn't
apply. =)

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


TT (Tom Tempelaere) said:
Hi,

If I change the thread priority when the thread is running, will this
have
any effect (ie will thread priority effectively be changed)?
Thread wThread = ...;
// ...
wThread.Start();

// ...
wTread.Priority = ThreadPriority.AboveNormal;

Thanks,
Tom Tempelaere.
 
Back
Top