Reputation: 665
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 that runs this action? I know how can I do it in simple thread.
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
But how about an action's priority?
Upvotes: 3
Views: 2365
Reputation:
BeginInvoke will queue your task to the ThreadPool. You have no control over the dispatching of the standard .NET ThreadPool. You can only control the thread once your code actually executes.
WARNING: Changing priority of a ThreadPool Thread is considered dangerous. Further Reading: .NET: Why not change the priority of a ThreadPool (or Task) thread?
If you can explain what you're trying to achieve, perhaps you can get a better solution?
Upvotes: 4