Saturday, December 4, 2010

Working with threads in console application.

In C#, you create a thread by creating an object of type Thread, giving its constructor a ThreadStart reference, and calling the new thread’s Start ( ) method. The new thread starts executing asynchronously with an invocation of the thread’s method. When the method returns, the thread dies.

The other methods of the Thread class allow managing the lifetime of the thread and destroying the thread when required. There are various methods available with the Thread class. Using these methods, you can control the execution of threads.
Few of these methods are:
Start ( ) :
Starts a thread.
Sleep ( ) : makes the thread to pause for a period of time.
Abort ( )
: Terminates the thread.
Suspend ( ) : Suspends a thread. If the thread is already suspended it has no effect.
Resume ( ) : Resumes the suspended thread.

Note: -
Working with threads involves creating, managing and destroying threads.

No comments:

Recent Posts