Search Forum
(53671 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


 
Printable Version

How To Thread in C#, Part I
By Randy Charles Morin

One of my New Year wishes for this coming year was that the standard committees would agree on threading classes for the C++ language. This limitation of the C++ language standard means that I have to rewrite my threading library each time I start a new job with a new company. I've always wished there was a standard threading library that I could use wherever I go.

Fortunately, C# does not have this disadvantage. Right from the get go, the language inherits an entire set of threading classes from the dotNet framework. Th e dotNet namespaces includes 14 utility classes, 4 exception classes, 2 structures, 6 delegates and 3 enumerations. I'll present most of these in this article.

Intermediate Level

This article is written for the intermediate and senior C# developer. Working knowledge of the C# programming language and dotNet framework is assumed. The article was written with a Beta version of VS.NET and associated documentation. Changes, although not anticipated, might occur before final release of VS.NET that invalidate portions of this article.

Creating Threads

Creating a thread in C# is close to trivial, but not quite. The only non-trivial thing about creating a thread is dotNet delegate-classes. Let me explain in few words what is a delegate class. The delegate is a wrapper around a code construct in the dotNet. The code construct could be an object instance, an instance method or a static method. Delegates are used when you want to pass one of the three code constructs as a parameter to another method.

[Continued]

Copyright 2002-03 Randy Charles Morin