I have a multi-threaded application with (4) thread i want to know how much processing time spent in threads. I've created all these threads with ThreadPool
Thread1 doing job1
Thread2 doing job2
..
..
result would be:
Thread1 was running in 12 millisecond
Thread2 was running in 20 millisecond
I've actually download a web page in a job that each job is processing in one thread i want to know how much time it takes a web page is downloaded (without the affection of other threads context switch in calculated time
If your ThreadPool runs out of threads two things may happen: All opperations are queued until the next resource is available. If there are finished threads those might still be "in use" so the GC will trigger and free up some of them, providing you with new resources.
The life cycle of a thread is started when instance of System. Threading. Thread class is created. When the task execution of the thread is completed, its life cycle is ended.
The maximum allowed number of processing threads in a pool is 1023. The pool allocates a maximum of 1000 threads in an I/O operation. To get maximum number of threads, you can use the GetMaxThreads method of the ThreadPool static class.
Threads are tasks that can run concurrently to other threads and can share data. When your program starts, it creates a thread for the entry point of your program, usually a Main function. So, you can think of a "program" as being made up of threads.
I found this code on codeproject:
http://www.codeproject.com/KB/dotnet/ExecutionStopwatch.aspx
Try it and report back ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With