PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Thread Priority

Reply

Thread Priority

 
Thread Tools Rate Thread
Old 02-06-2005, 03:34 PM   #1
=?Utf-8?B?Q2hyaXMgQ3JhYnRyZWU=?=
Guest
 
Posts: n/a
Default Thread Priority


My Windows Form app needs a lower priority. With VS.NET 2003, I could do
something like:
System.Threading.Thread.CurrentThread.Priority =
System.Threading.ThreadPriority.Lowest;

This still compiles in VS.NET 2005 Beta 1 and Beta 2, but has no apparent
effect on the actual priority.

I've set this in Program.cs as well as the form itself, thinking I might've
treated the wrong thread...all to no avail.

Is there a different way to do this in .NET2?

Thanks!
  Reply With Quote
Old 05-06-2005, 05:52 PM   #2
Willy Denoyette [MVP]
Guest
 
Posts: n/a
Default Re: Thread Priority


"Chris Crabtree" <chris@discussions.microsoft.com> wrote in message
news:F68B5062-13A7-4F9A-87E6-FB32FF01B061@microsoft.com...
> My Windows Form app needs a lower priority. With VS.NET 2003, I could do
> something like:
> System.Threading.Thread.CurrentThread.Priority =
> System.Threading.ThreadPriority.Lowest;
>
> This still compiles in VS.NET 2005 Beta 1 and Beta 2, but has no apparent
> effect on the actual priority.
>
> I've set this in Program.cs as well as the form itself, thinking I
> might've
> treated the wrong thread...all to no avail.
>
> Is there a different way to do this in .NET2?
>
> Thanks!


Works for me, the base priority of the main (UI) thread is set to 6, while 8
= normal. How are you looking at the thread priority? I'm also not clear on
why you need this for, there is in general no need to change the thread
priority of a foreground process and certainly not the UI threads priority.

Willy.


  Reply With Quote
Old 05-06-2005, 10:44 PM   #3
=?Utf-8?B?Q2hyaXMgQ3JhYnRyZWU=?=
Guest
 
Posts: n/a
Default Re: Thread Priority

Thanks for the response, Willy.

I am looking at the priority through the Processes tab in Task Manager. I
context-click, choose Set Priority and notice which option is marked. It
remains marked 'Normal' despite the code we discussed. I can of course
manually mark it as 'Low' within Task Manager, but this quickly becomes
tiresome and if I need it to run with Low priority on a user's machine, Task
Manager isn't really a good solution.

How are you checking the priority so that you see it as a 6?

As to why I would want to do this, it comes up quite a bit.

For example, if I am running a full suite of test cases through an app, it
takes anywhere from ten minutes to overnight depending on what I am doing
exactly. I need to be able to work effectively on other things while this is
running, so this seems to be exactly what priorities are for.

Another example is a file comparison/copy operation that I need to run on a
user's machine. It will take a while just by the nature of the amount of data
involved. In this case I definitely need the app to play with other apps on
the user's system. Especially so here because the user may not even have
permissions to modify the process priority, even if I were inclined to show
him how (which I am not :-)).

Thanks!
"Willy Denoyette [MVP]" wrote:

>
> "Chris Crabtree" <chris@discussions.microsoft.com> wrote in message
> news:F68B5062-13A7-4F9A-87E6-FB32FF01B061@microsoft.com...
> > My Windows Form app needs a lower priority. With VS.NET 2003, I could do
> > something like:
> > System.Threading.Thread.CurrentThread.Priority =
> > System.Threading.ThreadPriority.Lowest;
> >
> > This still compiles in VS.NET 2005 Beta 1 and Beta 2, but has no apparent
> > effect on the actual priority.
> >
> > I've set this in Program.cs as well as the form itself, thinking I
> > might've
> > treated the wrong thread...all to no avail.
> >
> > Is there a different way to do this in .NET2?
> >
> > Thanks!

>
> Works for me, the base priority of the main (UI) thread is set to 6, while 8
> = normal. How are you looking at the thread priority? I'm also not clear on
> why you need this for, there is in general no need to change the thread
> priority of a foreground process and certainly not the UI threads priority.
>
> Willy.
>
>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off