C# Program to display priority of Thread

CsharpServer Side ProgrammingProgramming

<p style="">To show the priority of the thread in C#, use the <strong>Priority</strong> property.</p><p style="">Firstly, use the <strong>currentThread</strong> property to display information about a thread &minus;</p><pre class="result notranslate">Thread thread = Thread.CurrentThread;</pre><p style="">Now use the <strong>thread.Priority</strong> property to display the priority of the thread &minus;</p><pre class="result notranslate" style="">thread.Priority</pre><h2 style="">Example</h2><p style="">Let us see the complete code to show the thread&rsquo;s priority in C#.</p><p style=""><a class="demo" href="http://tpcg.io/7eO5qi" rel="nofollow" target="_blank">Live Demo</a></p><pre class="result notranslate" style="">using System; using System.Threading; namespace Demo { &nbsp; &nbsp;class MyClass { &nbsp; &nbsp; &nbsp; static void Main(string[] args) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Thread thread = Thread.CurrentThread; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;thread.Name = &quot;My Thread&quot;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(&quot;Thread Priority = {0}&quot;, thread.Priority); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.ReadKey(); &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;} }</pre><h2 style="">Output</h2><pre class="result notranslate">Thread Priority = Normal</pre>
raja
Updated on 19-Jun-2020 11:16:52

Advertisements