![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if a thread belongs to managed thread pool or not in C#
To check if a thread belongs to managed thread pool or not, the code is as follows −
Example
using System; using System.Threading; public class Demo { public static void Main() { Thread thread = new Thread(new ThreadStart(demo)); thread.Start(); } public static void demo() { Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread); } }
Output
This will produce the following output −
Thread belongs to managed thread pool? = False
Example
Let us see another example −
using System; using System.Threading; public class Demo { public static void Main() { ThreadPool.QueueUserWorkItem(new WaitCallback(demo)); } public static void demo(object stateInfo) { Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread); } }
Output
This will produce the following output −
Thread belongs to managed thread pool? = True
Advertisements