Search code examples
c#multithreadingthread-priority

Set Thread priority with console.readline? c#


I'm wondering if you can change the priority of a thread by letting the user enter a string (Lowest, BelowNormal etc)? As far as I know, the "ThreadPriority" is an enum but I don't know how to do it.

thread.Priority = ThreadPriority.BelowNormal

How can I change the BelowNormal to something the user enter (ReadLine)?

Thanks!


Solution

  • thread.Priority = (ThreadPriority)Enum.Parse(typeof(ThreadPriority), Console.ReadLine());