Changing the priority of an action thread

I have an action

var act = new Action(() =>
{
   while (true)
   {
     //Some Codes!
   }
 });
 act.BeginInvoke(null, null);

      

How can I increase the priority of the thread performing this action? I know how I can do this in a simple thread.

Thread.CurrentThread.Priority = ThreadPriority.Lowest;

      

But what about priority action?

+3


source to share


1 answer


BeginInvoke will put your task in the ThreadPool. You have no control over the dispatch of the standard .NET ThreadPool. You can only control the flow after executing the code.

WARNING: Changing the ThreadPool Thread priority is considered dangerous. Further reading: .NET: Why not change the priority of the ThreadPool (or Task) thread?



If you can explain what you are trying to achieve, perhaps you can get a better solution?

+4


source







All Articles