In C#, before you use threads, consider whether you can do the same thing just using events or delegates (i.e. built-in, implicit threading).
If you want to create threads explicitly, you can use System.Threading namespace. Useful stuff in this namespace include the ThreadPool class, and the Timer class, which will execute callbacks on thread pool threads.
The Thread class is a sealed class i.e. cannot be subclassed (structs, can be used for lighweight objects e.g. Point, Color, can are implicitly sealed. You cannot subclass a struct).
Thread th = new Thread( new ThreadStart(display) ); // display is a method
th.IsBackground = true;
th.Start();
An interesting article on deadlock in C# is here.
If you want to create threads explicitly, you can use System.Threading namespace. Useful stuff in this namespace include the ThreadPool class, and the Timer class, which will execute callbacks on thread pool threads.
The Thread class is a sealed class i.e. cannot be subclassed (structs, can be used for lighweight objects e.g. Point, Color, can are implicitly sealed. You cannot subclass a struct).
Thread th = new Thread( new ThreadStart(display) ); // display is a method
th.IsBackground = true;
th.Start();
An interesting article on deadlock in C# is here.
No comments:
Post a Comment