06-06-2013, 04:22 PM
Multithreading in C#
Multithreading.pptx (Size: 45.2 KB / Downloads: 13)
introduction
C# supports the concept of multithreading which enables us to execute two or more parts of a program
Each part is known as thread
A thread is basically a sequence of instructions designed to perform “Specific Task” in the program
So multithreading means, performing the multiple task at same time
The execution of C# program starts with a single thread called the main thread is automatically run by the CLR
From main thread, we can create other threads
The process of creating multiple thread is known as multithreading programming
Advantage
Efficient programming
Optimize use of computers resources such as memory, I/O
To invoke thread in C#, namespace System.Threading
Mutex Class
It is a synchronization primitives that helps to performs IPC in C#
It allows a thread to have exclusive access to shared resources
When thread acquires mutex, another thread is suspended until first thread release mutex
Creating And Starting The Thread
Thread threadname=new Thread(new ThreadStart(methodname));
We need to pass ThreadStart Delegate to the Thread class constructor passes the method from which execution start.
The delegate is defined as :
Public delegate void ThreadStart();