Running parts of my application with a different CPU priority

Got a c # application for winform.

Allows you to display a stream of images (for example, video).

I also upload these jpegs 1 to my web server and the user can view these jpeg (e.g. video).

In an effort to make my code as efficient as possible, I was wondering if I can execute the part of my code that is responsible for loading these images under a different priority - for example, in real time?

Is it possible?

If so..

Should I transfer the class object responsible for loading these images into an external DLL? Then how do I β€œrun” it under a different process priority?

If all of this is possible, and if I agree to a possible compromise of other processes on my PC that may be affected by all this, will this really give me improved performance?

thanks

+4
source share
3 answers

I don’t think that thread priorities will help you solve the problem, but if you want β€œyes”, you can change the thread priority in C #, and you also have many libraries that help you control the flow, for example

  • TPL, PLINQ
  • Tasks
  • Async await
  • Backgroundworker
  • Themes, etc. FROM#.

TPL for a parallel task library is very efficient for multiple processors.

, - , .

using (Process p = Process.GetCurrentProcess())
  p.PriorityClass = ProcessPriorityClass.High;

enum ThreadPriority { Lowest, BelowNormal, Normal, AboveNormal, Highest }

/ , . :

#

+1

, . I.e., , , .

. / .

, , - , ?

...

?

, .

Windows . , , I/O, .

.

+2

, , , Thread.Priority.

Another option is to run high-priority code in a separate process and change the priority of the process level. This may provide slightly better performance than relying on thread priority, but it will add extra complexity as you now have the overhead of interprocess communication with the rest of your application.

You can read this article on MSDN on the Windows Task Scheduler Priority System .

+1
source

All Articles