<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5435296901528620140</id><updated>2012-02-16T17:55:00.945-08:00</updated><category term='FAQ'/><category term='Visual C#.Net'/><title type='text'>Microsoft Visual C#, C#.Net Interview Questions and Answers</title><subtitle type='html'>C#.Net C#, ADO, ASP, Frequently asked questions</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-794023808186493106</id><published>2009-07-15T08:37:00.000-07:00</published><updated>2009-07-15T08:37:00.142-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What are the new features in C# 2.0?</title><content type='html'>Support for all of the new framework features such as generics, anonymous methods, partial classes, iterators and static classes. See the .NET FAQ for more on these features.&lt;br /&gt;Delegate inference is a new feature of the C# compiler which makes delegate usage a little simpler. It allows you to write this:&lt;br /&gt;   Thread t = new Thread(ThreadFunc);&lt;br /&gt;instead of this:&lt;br /&gt;   Thread t = new Thread( new ThreadStart(ThreadFunc) );&lt;br /&gt;Another minor but welcome addition is the explicit global namespace, which fixes a hole in namespace usage in C# 1.x. You can prefix a type name with global:: to indicate that the type belongs to the global namespace, thus avoiding problems where the compiler infers the namespace and gets it wrong.&lt;br /&gt;Finally C# 2.0 includes some syntactic sugar for the new System.Nullable type. You can use T? as a synonym for System.Nullable&lt;t&gt;, where T is a value type. As suggested by the name, this allows values of the type to be 'null', or 'undefined'.&lt;/t&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-794023808186493106?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/794023808186493106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=794023808186493106' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/794023808186493106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/794023808186493106'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-are-new-features-in-c-20.html' title='What are the new features in C# 2.0?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2510517444871263563</id><published>2009-07-14T08:36:00.000-07:00</published><updated>2009-07-14T08:36:00.174-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Are C# generics the same as C++ templates?</title><content type='html'>No, not really. There are some similarities, but there are also fundamental differences. See the .NET FAQ for more details&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2510517444871263563?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2510517444871263563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2510517444871263563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2510517444871263563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2510517444871263563'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/are-c-generics-same-as-c-templates.html' title='Are C# generics the same as C++ templates?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-4059309684244295976</id><published>2009-07-13T08:22:00.000-07:00</published><updated>2009-07-13T08:22:00.568-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Does C# support multiple inheritance?</title><content type='html'>No, use interfaces instead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-4059309684244295976?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/4059309684244295976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=4059309684244295976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/4059309684244295976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/4059309684244295976'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/does-c-support-multiple-inheritance.html' title='Does C# support multiple inheritance?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-1072472434956661649</id><published>2009-07-12T08:22:00.000-07:00</published><updated>2009-07-12T08:22:00.931-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do you inherit from a class in C#?</title><content type='html'>Place a colon and then the name of the base class. Notice that it's double colon in C++.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-1072472434956661649?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/1072472434956661649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=1072472434956661649' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/1072472434956661649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/1072472434956661649'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-you-inherit-from-class-in-c.html' title='How do you inherit from a class in C#?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3239191086184174195</id><published>2009-07-11T08:22:00.000-07:00</published><updated>2009-07-11T08:22:00.169-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the implicit name of the parameter that gets passed into the class' set method?</title><content type='html'>Value, and it's datatype depends on whatever variable we're changing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3239191086184174195?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3239191086184174195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3239191086184174195' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3239191086184174195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3239191086184174195'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-implicit-name-of-parameter-that.html' title='What&apos;s the implicit name of the parameter that gets passed into the class&apos; set method?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2370617130423846429</id><published>2009-07-10T08:21:00.000-07:00</published><updated>2009-07-10T08:21:00.821-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Can you change the value of a variable while debugging a C# application?</title><content type='html'>Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2370617130423846429?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2370617130423846429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2370617130423846429' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2370617130423846429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2370617130423846429'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/can-you-change-value-of-variable-while.html' title='Can you change the value of a variable while debugging a C# application?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5118748043435090458</id><published>2009-07-09T08:20:00.000-07:00</published><updated>2009-07-09T08:20:00.777-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do you generate documentation from the C# file commented properly with a command-line compiler?</title><content type='html'>Compile it with a /doc switch.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5118748043435090458?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5118748043435090458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5118748043435090458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5118748043435090458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5118748043435090458'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-you-generate-documentation-from.html' title='How do you generate documentation from the C# file commented properly with a command-line compiler?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-650823525842702494</id><published>2009-07-08T08:18:00.000-07:00</published><updated>2009-07-08T08:18:01.881-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What does it meant to say “the canonical” form of XML?</title><content type='html'>"The purpose of Canonical XML is to define a standard format for an XML document. Canonical XML is a very strict XML syntax, which lets documents in canonical XML be compared directly.&lt;br /&gt;Using this strict syntax makes it easier to see whether two XML documents are the same. For example, a section of text in one document might read Black &amp;amp; White, whereas the same section of text might read Black &amp;amp; White in another document, and even in another. If you compare those three documents byte by byte, they'll be different. But if you write them all in canonical XML, which specifies every aspect of the syntax you can use, these three documents would all have the same version of this text (which would be Black &amp;amp; White) and could be compared without problem.&lt;br /&gt;This Comparison is especially critical when xml documents are digitally signed. The digital signal may be interpreted in different way and the document may be rejected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-650823525842702494?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/650823525842702494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=650823525842702494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/650823525842702494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/650823525842702494'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-does-it-meant-to-say-canonical.html' title='What does it meant to say “the canonical” form of XML?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5535075732367508865</id><published>2009-07-06T08:18:00.000-07:00</published><updated>2009-07-06T08:18:03.808-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is the difference between an XML "Fragment" and an XML "Document."</title><content type='html'>An XML fragment is an XML document with no single top-level root element. To put it simple it is a part (fragment) of a well-formed xml document. (node) Where as a well-formed xml document must have only one root element.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5535075732367508865?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5535075732367508865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5535075732367508865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5535075732367508865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5535075732367508865'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-difference-between-xml-fragment.html' title='What is the difference between an XML &quot;Fragment&quot; and an XML &quot;Document.&quot;'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2338988694941960757</id><published>2009-07-05T08:17:00.000-07:00</published><updated>2009-07-05T08:17:00.826-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How is a property designated as read-only?</title><content type='html'>Private DataType mPropertyName;&lt;br /&gt;public returntype PropertyName&lt;br /&gt;{&lt;br /&gt;     get{&lt;br /&gt;                       //property implementation goes here&lt;br /&gt;                       return mPropertyName;&lt;br /&gt;           }&lt;br /&gt;           // Do not write the set implementation&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2338988694941960757?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2338988694941960757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2338988694941960757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2338988694941960757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2338988694941960757'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-is-property-designated-as-read-only.html' title='How is a property designated as read-only?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3601071251973522496</id><published>2009-07-04T08:16:00.000-07:00</published><updated>2009-07-04T08:16:00.166-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How would you implement inheritance using VB.NET/C#?</title><content type='html'>When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of some other application or .NET assembly, or we may create it as part of our existing application. Once we have a base class, we can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the methods, properties, and events of that base class ? including the implementation behind each method, property, and event. Our subclass can add new methods, properties, and events of its own - extending the original interface with new functionality. Additionally, a subclass can replace the methods and properties of the base class with its own new&lt;br /&gt;implementation - effectively overriding the original behavior and replacing it with new behaviors. Essentially inheritance is a way of merging functionality from an existing class into our new subclass. Inheritance also defines rules for how these methods, properties, and events can be merged. In VB.NET we can use implements keyword for inheritance, while in C# we can use the sign ( : ) between subclass and baseclass.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3601071251973522496?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3601071251973522496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3601071251973522496' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3601071251973522496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3601071251973522496'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-would-you-implement-inheritance.html' title='How would you implement inheritance using VB.NET/C#?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7102870949538426695</id><published>2009-07-03T08:15:00.000-07:00</published><updated>2009-07-03T08:15:00.744-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How does VB.NET/C# achieve polymorphism?</title><content type='html'>Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also describe the methods that a class needs to implement. The difference between abstract classes and interfaces is that abstract classes always act as a base class of the related classes in the class hierarchy. For example, consider a hierarchy-car and truck classes derived from four-wheeler class; the classes two-wheeler and four-wheeler derived from an abstract class vehicle. So, the class 'vehicle' is the base class in the class hierarchy. On the other hand dissimilar classes can implement one interface. For example, there is an interface that compares two objects. This interface can be implemented by the classes like box, person and string, which are unrelated to each other.&lt;br /&gt;C# allows multiple interface inheritance. It means that a class can implement more than one interface. The methods declared in an interface are implicitly abstract. If a class implements an interface, it becomes mandatory for the class to override all the methods declared in the interface, otherwise the derived class would become abstract.&lt;br /&gt;Can you explain what inheritance is and an example of when you might use it?&lt;br /&gt;The savingaccount class has two data members-accno that stores account number, and trans that keeps track of the number of transactions. We can create an object of savingaccount class as shown below.&lt;br /&gt;       savingaccount s = new savingaccount ( "Amar", 5600.00f ) ;&lt;br /&gt;From the constructor of savingaccount class we have called the two-argument constructor of the account class using the base keyword and passed the name and balance to this constructor using which the data member's name and balance are initialised.&lt;br /&gt;We can write our own definition of a method that already exists in a base class. This is called method overriding. We have overridden the deposit( ) and withdraw( ) methods in the savingaccount class so that we can make sure that each account maintains a minimum balance of Rs. 500 and the total number of transactions do not exceed 10. From these methods we have called the base class's methods to update the balance using the base keyword. We have also overridden the display( ) method to display additional information, i.e. account number.&lt;br /&gt;Working of currentaccount class is more or less similar to that of savingaccount class.&lt;br /&gt;Using the derived class's object, if we call a method that is not overridden in the derived class, the base class method gets executed. Using derived class's object we can call base class's methods, but the reverse is not allowed.&lt;br /&gt;Unlike C++, C# does not support multiple inheritance. So, in C# every class has exactly one base class.&lt;br /&gt;Now, suppose we declare reference to the base class and store in it the address of instance of derived class as shown below.&lt;br /&gt;       account a1 = new    savingaccount ( "Amar", 5600.00f ) ;&lt;br /&gt;  account a2 = new currentaccount ( "MyCompany Pvt. Ltd.", 126000.00f) ;&lt;br /&gt;Such a situation arises when we have to decide at run-time a method of which class in a class hierarchy should get called. Using a1 and a2, suppose we call the method display( ), ideally the method of derived class should get called. But it is the method of base class that gets called. This is because the compiler considers the type of reference (account in this case) and resolves the method call. So, to call the proper method we must make a small change in our program. We must use the virtual keyword while defining the methods in base class as shown below.&lt;br /&gt;       public virtual void display( )    {   }&lt;br /&gt;We must declare the methods as virtual if they are going to be overridden in derived class. To override a virtual method in derived classes we must use the override keyword as given below.&lt;br /&gt;       public override void display( )   {   }&lt;br /&gt;Now it is ensured that when we call the methods using upcasted reference, it is the derived class's method that would get called. Actually, when we declare a virtual method, while calling it, the compiler considers the contents of the reference rather than its type.&lt;br /&gt;If we don't want to override base class's virtual method, we can declare it with new modifier in derived class. The new modifier indicates that the method is new to this class and is not an override of a base class method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7102870949538426695?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7102870949538426695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7102870949538426695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7102870949538426695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7102870949538426695'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-does-vbnetc-achieve-polymorphism.html' title='How does VB.NET/C# achieve polymorphism?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-673219440153876247</id><published>2009-07-02T07:51:00.000-07:00</published><updated>2009-07-02T07:51:01.336-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do I run managed code in a process?</title><content type='html'>The first step in running managed code in a process is to get the CLR loaded and initialized using a CLR host. Typically, a host consists of both managed code and unmanaged code. The managed code which executes in the default domain is usually responsible for creating the application domains in which the user code exists. All CLR hosts must contain unmanaged code because execution must begin in unmanaged code. The .NET Frameworks provides a set of unmanaged APIs that the host can use to configure the CLR, load the CLR into a process, load the hosts managed code into the default domain, and transition from the unmanaged code to the managed code.&lt;br /&gt;The second step in running managed code in a process is to create application domains in which the user code will execute. The creator of the application domain can specify criteria which control code isolation, security, and loading of assemblies.&lt;br /&gt;The third step in running managed code in a process is to execute user code in one or more application domains created in the previous step. All code that is run in the CLR must be part of an assembly. There are three options for loading assemblies. First, precompiled assemblies can be loaded from disk. Second, precompiled assemblies can be loaded from an array of bytes. Third, assemblies can be built dynamically in an application domain using the BCL Reflection Emit APIs.&lt;br /&gt;Note. For an application launched from the command-line, the shell host executes the steps described above on behalf of the user and hides the complexity from the user.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-673219440153876247?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/673219440153876247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=673219440153876247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/673219440153876247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/673219440153876247'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-i-run-managed-code-in-process.html' title='How do I run managed code in a process?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2485945937692452602</id><published>2009-07-01T08:15:00.000-07:00</published><updated>2009-07-01T08:15:01.442-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Explain the differences between Server-side and Client-side code?</title><content type='html'>Server side code executes on the server.For this to occur page has to be submitted or posted back.Events fired by the controls are executed on the server.Client side code executes in the browser of the client without submitting the page.&lt;br /&gt;e.g. In ASP.NET for webcontrols like asp:button the click event of the button is executed on the server hence the event handler for the same in a part of the code-behind (server-side code). Along the server-side code events one can also attach client side events which are executed in the clients browser i.e. javascript events.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2485945937692452602?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2485945937692452602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2485945937692452602' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2485945937692452602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2485945937692452602'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/explain-differences-between-server-side.html' title='Explain the differences between Server-side and Client-side code?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3491381975731282754</id><published>2009-06-30T07:50:00.000-07:00</published><updated>2009-06-30T07:50:00.245-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is an assembly?</title><content type='html'>An assembly is a reusable, versionable, self-describing deployment unit for types and resources it is the primary building block of a .NET application. Assemblies provide the infrastructure to allow the runtime to fully understand the contents of an application and to enforce the versioning and dependency rules defined by the application.&lt;br /&gt;An assembly consists of the following two logical elements:&lt;br /&gt;        The sets of types and resources that form some logical unit of functionality.&lt;br /&gt;        A manifest which is the metadata that describes how the types and resources relate and what they depend on to work properly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3491381975731282754?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3491381975731282754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3491381975731282754' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3491381975731282754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3491381975731282754'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-assembly.html' title='What is an assembly?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5610843076222428320</id><published>2009-06-29T07:48:00.000-07:00</published><updated>2009-06-29T07:48:00.641-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do I dynamically resolve assemblies, types, and resources?</title><content type='html'>The assembly resolution is controlled by the configuration properties for the application domain such as System.AppDomainSetup.ApplicationBase. The configuration properties may not be sufficient in some hosting scenarios, especially if the host is creating assemblies in memory on the fly using Reflection Emit, since there may not be an assembly on disk to find. In such cases, you can use the System.AssemblyResolve event to hook into the type loading process.&lt;br /&gt;The AssemblyResolve event is defined as follows:&lt;br /&gt;public event ResolveEventHandler AssemblyResolve&lt;br /&gt;where System.ResolveEventHandler is defined as follows:&lt;br /&gt;public delegate Assembly ResolveEventHandler(Object sender, ResolveEventArgs args)&lt;br /&gt;The args parameter to ResolveEventHandler is the identity of the assembly the runtime is seeking. The receipient of the event is free to resolve the reference to the assembly by any means. For example, the receipient may construct an assembly on the fly, find it in a custom location on disk, etc. The only requirement is that the receipient return a instance of System.Reflection.Assembly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5610843076222428320?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5610843076222428320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5610843076222428320' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5610843076222428320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5610843076222428320'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-i-dynamically-resolve-assemblies.html' title='How do I dynamically resolve assemblies, types, and resources?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3642500269575893763</id><published>2009-06-29T07:46:00.000-07:00</published><updated>2009-06-29T07:46:01.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?</title><content type='html'>Document Type Definition (DTD) describes a model or set of rules for an XML document. XML Schema Definition (XSD) also describes the structure of an XML document but XSDs are much more powerful.&lt;br /&gt;The disadvantage with the Document Type Definition is it doesn’t support data types beyond the basic 10 primitive types. It cannot properly define the type of data contained by the tag.&lt;br /&gt;An Xml Schema provides an Object Oriented approach to defining the format of an xml document. The Xml schema support most basic programming types like integer, byte, string, float etc., We can also define complex types of our own which can be used to define a xml document.&lt;br /&gt;Xml Schemas are always preferred over DTDs as a document can be more precisely defined using the XML Schemas because of its rich support for data representation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3642500269575893763?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3642500269575893763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3642500269575893763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3642500269575893763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3642500269575893763'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/contrast-dtds-versus-xsds-what-are.html' title='Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-8383307576123629130</id><published>2009-06-28T07:45:00.000-07:00</published><updated>2009-06-28T07:45:01.071-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Where do you add an event handler?</title><content type='html'>It's the Attributesproperty, the Add function inside that property.&lt;br /&gt;e.g. btnSubmit.Attributes.Add(""onMouseOver"",""someClientCode();"")&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-8383307576123629130?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/8383307576123629130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=8383307576123629130' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8383307576123629130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8383307576123629130'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/where-do-you-add-event-handler.html' title='Where do you add an event handler?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7863093867267033220</id><published>2009-06-27T07:45:00.000-07:00</published><updated>2009-06-27T07:45:00.552-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What are jagged array ?</title><content type='html'>First lets us answer the question that what an array is?&lt;br /&gt;The dictionary meaning of array is an orderly arrangement or sequential arrangement of elements.&lt;br /&gt;In computer science term:&lt;br /&gt;An array is a data structure that contains a number of variables, which are accessed through computed indices. The variables contained in an array, also called the elements of the array, are all of the same type, and this type is called the element type of the array.&lt;br /&gt;An array has a rank that determines the number of indices associated with each array element. The rank of an array is also referred to as the dimensions of the array. An array with a rank of one is called a single-dimensional array. An array with a rank greater than one is called a multi-dimensional array. Specific sized multidimensional arrays are often referred to as two-dimensional arrays, three-dimensional arrays, and so on.&lt;br /&gt;Now let us answer What are jagged arrays?&lt;br /&gt;A jagged array is an array whose elements are arrays. The elements of jagged array can be of different dimensions and sizes. A jagged array is sometimes called as “array-of-arrays”. It is called jagged because each of its rows is of different size so the final or graphical representation is not a square.&lt;br /&gt;When you create a jagged array you declare the number of rows in your array. Each row will hold an array that will be on any length. Before filling the values in the inner arrays you must declare them.&lt;br /&gt;Jagged array declaration in C#:&lt;br /&gt;For e.g. : int [] [] myJaggedArray = new int [3][];&lt;br /&gt;Declaration of inner arrays:&lt;br /&gt;&lt;br /&gt;myJaggedArray[0] = new int[5] ;   // First inner array will be of length 5.&lt;br /&gt;myJaggedArray[1] = new int[4] ;  // Second inner array will be of length 4.&lt;br /&gt;myJaggedArray[2] = new int[3] ;   // Third inner array will be of length 3.&lt;br /&gt;Now to access third element of second row we write:&lt;br /&gt; int value = myJaggedArray[1][2];&lt;br /&gt;Note that while declaring the array the second dimension is not supplied because this you will declare later on in the code.&lt;br /&gt;Jagged array are created out of single dimensional arrays so be careful while using them. Don’t confuse it with multi-dimensional arrays because unlike them jagged arrays are not rectangular arrays.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7863093867267033220?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7863093867267033220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7863093867267033220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7863093867267033220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7863093867267033220'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-are-jagged-array.html' title='What are jagged array ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2986914339178393640</id><published>2009-06-26T07:44:00.000-07:00</published><updated>2009-06-26T07:44:00.596-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>If you define integer variable and a object variable and a structure then how those will be plotted in memory.</title><content type='html'>Integer , structure – System.ValueType  -- Allocated memory on stack , infact integer is primitive type recognized and allocated memory by compiler itself .&lt;br /&gt;Infact , System.Int32 definition is as follows :&lt;br /&gt;[C#]&lt;br /&gt;[Serializable]&lt;br /&gt;public struct Int32 : IComparable, IFormattable, IConvertible&lt;br /&gt;So , it’s a struct by definition , which is the same case with various other value types .&lt;br /&gt;Object – Base class , that is by default reference type , so at runtime JIT compiler allocates memory on the “Heap” Data structure .&lt;br /&gt;Reference types are defined as class , derived directly or indirectly by System.ReferenceType&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2986914339178393640?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2986914339178393640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2986914339178393640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2986914339178393640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2986914339178393640'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/if-you-define-integer-variable-and.html' title='If you define integer variable and a object variable and a structure then how those will be plotted in memory.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7161653562287095946</id><published>2009-06-25T07:44:00.000-07:00</published><updated>2009-06-25T07:44:02.783-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is a delegate, why should you use it and how do you call it ?</title><content type='html'>A delegate is a reference type that refers to a Shared method of a type or to an instance method of an object. Delegate is like a function pointer in C and C++.  Pointers are used to store the address of a thing. Delegate lets some other code call your function without needing to know where your function is actually located. All events in .NET actually use delegates in the background to wire up events. Events are really just a modified form of a delegate.&lt;br /&gt;It should give you an idea of some different areas in which delegates may be appropriate:&lt;br /&gt; They enable callback functionality in multi-tier applications as demonstrated in the examples above. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt; The CacheItemRemoveCallback delegate can be used in ASP.NET to keep cached information up to date. When the cached information is removed for any reason, the associated callback is exercised and could contain a reload of the cached information. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt; Use delegates to facilitate asynchronous processing for methods that do not offer asynchronous behavior.&lt;br /&gt; Events use delegates so clients can give the application events to call when the event is fired. Exposing custom events within your applications requires the use of delegates.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7161653562287095946?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7161653562287095946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7161653562287095946' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7161653562287095946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7161653562287095946'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-delegate-why-should-you-use-it.html' title='What is a delegate, why should you use it and how do you call it ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5077300570670082706</id><published>2009-06-24T07:09:00.000-07:00</published><updated>2009-06-24T07:09:00.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?</title><content type='html'>A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5077300570670082706?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5077300570670082706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5077300570670082706' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5077300570670082706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5077300570670082706'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-c-equivalent-of-c-catch-which-was.html' title='What&apos;s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5906287118714709978</id><published>2009-06-23T07:07:00.000-07:00</published><updated>2009-06-23T07:07:00.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the difference between const and readonly?</title><content type='html'>The readonly keyword is different from the const keyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants as in the following example:&lt;br /&gt;public static readonly uint l1 = (uint) DateTime.Now.Ticks;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5906287118714709978?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5906287118714709978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5906287118714709978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5906287118714709978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5906287118714709978'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-difference-between-const-and.html' title='What&apos;s the difference between const and readonly?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-8350604848488061275</id><published>2009-06-22T07:00:00.000-07:00</published><updated>2009-06-22T07:00:54.222-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is hiding in CSharp ?</title><content type='html'>Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming.&lt;br /&gt;&lt;br /&gt;E.g.&lt;br /&gt;public class ClassA {&lt;br /&gt;public virtual void MethodA() {&lt;br /&gt;Trace.WriteLine("ClassA Method");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class ClassB : ClassA {&lt;br /&gt;public new void MethodA() {&lt;br /&gt;Trace.WriteLine("SubClass ClassB Method");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class TopLevel {&lt;br /&gt;static void Main(string[] args) {&lt;br /&gt;TextWriter tw = Console.Out;&lt;br /&gt;Trace.Listeners.Add(new TextWriterTraceListener(tw));&lt;br /&gt;&lt;br /&gt;ClassA obj = new ClassB();&lt;br /&gt;obj.MethodA(); // Outputs “Class A Method"&lt;br /&gt;&lt;br /&gt;ClassB obj1 = new ClassB();&lt;br /&gt;obj.MethodA(); // Outputs “SubClass ClassB Method”&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-8350604848488061275?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/8350604848488061275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=8350604848488061275' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8350604848488061275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8350604848488061275'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-hiding-in-csharp.html' title='What is hiding in CSharp ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2455291705317858444</id><published>2008-10-23T03:32:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>The C# Tutorial</title><content type='html'>&lt;title&gt;Lesson 10&lt;/title&gt;&lt;span style="font-family:Trebuchet MS;"&gt; &lt;h3&gt;&lt;span style="color:#ff9900;"&gt;&lt;br /&gt;&lt;!--mstheme--&gt;&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;by Joe Mayo, 02/10/01&lt;/span&gt;&lt;/p&gt; &lt;h4&gt;&lt;!--mstheme--&gt;&lt;span style="color:#6666ff;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Lesson 10:  Properties&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h4&gt; &lt;p&gt;This lesson teaches C# Properties.  Our objectives are as follows:&lt;/p&gt;&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;&lt;!--msthemelist--&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Understand  What Properties Are For.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Implement a  Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Create a  Read-Only Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Create a  Write-Only Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt; &lt;p&gt;Properties are a new language feature introduced with C#.  They provide the  opportunity to protect a field in a class by reading and writing to it through  the property.  In other languages, this is accomplished by programs implementing  specialized getter and setter methods.  C# properties enable this type of  protection while also letting you access the property just like it was a field.   To get an appreciation for what properties accomplish, let's take a look at how  to provide field encapsulation by traditional methods.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-1.  An Example  of Traditional Class Field Access:  Accessors.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; getSomeProperty()&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;   &lt;span style="font-size:85%;color:#0000ff;"&gt;     return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;    public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  setSomeProperty(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  propValue)&lt;br /&gt;    {&lt;br /&gt;        someProperty = propValue;&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.setSomeProperty(5);&lt;br /&gt;&lt;br /&gt;         Console.WriteLine("Property Value: {0}",  propHold.getSomeProperty());&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-1 shows the traditional method of accessing class fields.  The  PropertyHolder class has the field we're interested in accessing.  It has two  methods, getSomeProperty and setSomeProperty.  The getSomeProperty method  returns the value of the someProperty field.  The setSomeProperty method sets  the value of the someProperty field.&lt;/p&gt; &lt;p&gt;The PropertyTester class uses the methods of the PropertyHolder class to get  the value of the someProperty field in the PropertyHolder class.  The Main  method instantiates a new PropertyHolder object, propHold.  Next it sets the  someMethod of propHold to the value 5 by using the setSomeProperty method.  Then  the program prints out the property value with a Console.WriteLine method call.   The argument used to obtain the value of the property is a call to the  getSomeProperty method of the propHold object.  It prints out "Property Value:  5" to the console.&lt;/p&gt; &lt;p&gt;This method of accessing information in a field has been good because it  supports the object-oriented concept of encapsulation.  If the implementation of  someProperty changed from an int type to a byte type, this would still work.   Now the same thing can be accomplished much smoother with properties.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-2.  Accessing  Class Fields With Properties:   Properties.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;             someProperty = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;span style="font-size:85%;"&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.SomeProperty = 5;&lt;br /&gt;&lt;br /&gt;         Console.WriteLine("Property Value: {0}", propHold.SomeProperty);&lt;br /&gt;&lt;br /&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;     }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-2 shows how to create and use a property.  The PropertyHolder  class has the "SomeProperty" property implementation.  Notice that the first  letter of the first word is capitalized.  That's the only difference between the  names of the property "SomeProperty" and the field "someProperty".  The property  has two accessors, get and set.  The get accessor returns the value of the  someProperty field.  The set accessor sets the value of the someProperty field  with the contents of "value".  The "value" shown in the set accessor is a C#  reserved word.  It's normally an error to use the "value" keyword in any other  context.&lt;/p&gt; &lt;p&gt;The PropertyTester class uses the SomeProperty property in the PropertyHolder  class.  The first line of the Main method creates a PropertyHolder object named  propHold.  Next the value of the someProperty field of the propHold object is  set to 5 by using the SomeProperty property.  It's that simple -- just assign  the value to the property as if it were a field.&lt;/p&gt; &lt;p&gt;After that, the Console.WriteLine method prints the value of the someProperty  field of the propHold object.  It does this by using the SomeProperty property  of the propHold object.  Again, it's that simple -- just use the property as if  it were a field itself.&lt;/p&gt; &lt;p&gt;Properties can be made read-only.  This is accomplished by having only a get  accessor in the property implementation.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-3.  Read-Only  Property:  ReadOnlyProperty.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyHolder(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; propVal)&lt;br /&gt;    {&lt;br /&gt;         someProperty = propVal;&lt;br /&gt;    }&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;&lt;br /&gt;     public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;        }&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder(5);&lt;br /&gt;&lt;br /&gt;        Console.WriteLine("Property Value: {0}",  propHold.SomeProperty);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-3 shows how to implement a read-only property.  The PropertyHolder  class has a SomeProperty property that only implements a get accessor.  It  leaves out the set accessor.  This particular PropertyHolder class has a  constructor which accepts an integer parameter.&lt;/p&gt; &lt;p&gt;The Main method of the PropertyTester class creates a new PropertyHolder  object named propHold.  The instantiation of the propHold object uses the  constructor of the PropertyHolder that takes an int parameter.  In this case,  it's set to 5.  This initializes the someProperty field of the propHold object  to 5.&lt;/p&gt; &lt;p&gt;Since the SomeProperty property of the PropertyHolder class is read-only,  there is no other way to set the value of the someProperty field.  If you  inserted "propHold.SomeProperty = 7" into the listing, the program would not  compile, because SomeProperty is read-only.  When the SomeProperty property is  used in the Console.WriteLine method, it works fine.  This is because it's a  read operation which only invokes the get accessor of the SomeProperty  property.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-4.  Write-Only  Property:  WriteOnlyProperty.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;             someProperty = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;span style="font-size:85%;"&gt;;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("someProperty is equal to {0}",  someProperty);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.SomeProperty = 5;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Listing 10-4 shows how to create and use a write-only property.  This time  the get accessor is removed from the SomeProperty property of the PropertyHolder  class.  The set accessor has been added, with a bit more logic.  It prints out  the value of the someProperty field after it's been modified.&lt;/p&gt; &lt;p&gt;The Main method of the PropertyTester class instantiates the PropertyTester  class with a default constructor.  Then it uses the SomeProperty property of the  propHold object to set the someProperty field of the propHold object to 5.  This  invokes the set accessor of the propHold object, which sets the value of it's  someProperty field to 5 and then prints "someProperty is equal to 5" to the  console.&lt;/p&gt; &lt;p&gt;In summary, you now know what properties are for and how they're used.  You  have a feeling for the difference between using properties and traditional  techniques using class methods.  Properties can be made read-only or write-only  and you know how to implement each type.&lt;/p&gt; &lt;p&gt;I invite you to return for Lesson 11:  Indexers.&lt;/p&gt; &lt;p&gt;Your feedback is very important and I appreciate any constructive  contributions you have. Please feel free to contact me for any questions or  comments you may have about this lesson&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2455291705317858444?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2455291705317858444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2455291705317858444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2455291705317858444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2455291705317858444'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/c-tutorial.html' title='The C# Tutorial'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5854982658058152331</id><published>2008-10-23T03:30:00.001-07:00</published><updated>2009-01-02T20:03:27.769-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='FAQ'/><title type='text'>C# Frequently Asked Questions for C++ programmers</title><content type='html'>&lt;title&gt;Andy Mc's C# FAQ for C++ programmers&lt;/title&gt;&lt;link href="csharpfaq_files/faq.css" type="text/css" rel="STYLESHEET"&gt;&lt;h2&gt;&lt;a name="1."&gt;1. Introduction&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="1.1"&gt;1.1 What is C#?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;C# is a programming language designed by Microsoft. It is loosely based on  C/C++, and bears a striking similarity to Java in many ways. Microsoft describe  C# as follows:&lt;/p&gt; &lt;p&gt;"C# is a simple, modern, object oriented, and type-safe programming language  derived from C and C++. C# (pronounced 'C sharp') is firmly planted in the C and  C++ family tree of languages, and will immediately be familiar to C and C++  programmers. C# aims to combine the high productivity of Visual Basic and the  raw power of C++."&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.2"&gt;1.2 When will C# be released?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No firm date yet, but it is expected in the second half of 2001.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.3"&gt;1.3 How do I develop C# apps?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;The .NET SDK contains the C# command-line compiler (csc.exe). The next  version of Visual Studio (called Visual Studio 7 or Visual Studio.NET) will have  fully integrated support for C# development. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.4"&gt;1.4 Where can I download the .NET SDK &amp;amp; Visual Studio  7?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;You can download Beta 1 of the SDK from &lt;a href="http://msdn.microsoft.com/net" target="_top"&gt;http://msdn.microsoft.com/net&lt;/a&gt;. If you are an MSDN Universal  subscriber, you can also download Beta 1 of Visual Studio 7.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.5"&gt;1.5 Does C# replace Java?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;C# is a very Java-like language - the core of both languages have similar  advantages and limitations when compared to C++. For example, both languages  have garbage collection, but neither language has templates. Microsoft have  ceased production of Visual J++, so it's hard not to view C# as Microsoft's  alternative to Java. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.6"&gt;1.6 Does C# replace C++?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;The obvious answer is no. However it's difficult to see C++ as the best  choice for new .NET code. For the .NET runtime to function fully, it requires  the programming language to conform to certain rules - one of these rules is  that language types must conform to the Common Type System (CTS). Unfortunately  many C++ features are not supported by the CTS - for example multiple  inheritance of classes and templates.&lt;/p&gt; &lt;p&gt;Microsoft's answer to this problem is to offer Managed Extensions (ME) for  C++, which allows you to write C++ that conforms to the CTS. New keywords are  provided to mark your C++ classes with CTS attributes (e.g. __gc for garbage  collection). However, it's difficult to see why ME C++ would be chosen over C#  for new projects. In terms of features they are very similar, but unlike C++, C#  has been designed from the ground-up to work seamlessly with the .NET  environment. The raison d'etre for ME C++ would therefore appear to be porting  existing C++ code to the .NET environment.&lt;/p&gt; &lt;p&gt;So, in answer to the question, my suspicion is that C++ will remain an  important language outside of the .NET environment, and will be used (via ME) to  port existing code to .NET, but I think C# will become the language of choice  for one-time C++ developers developing new .NET applications. But only time will  tell ...&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.7"&gt;1.7 What does a simple C# program look like?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Sorry, my imagination has deserted me. Yes, you guessed it, here comes  'Hello, world' ...&lt;/p&gt;&lt;pre class="code"&gt;class CApplication { 	public static void Main()  	{ 		System.Console.Write( "Hello, new .NET world." ); 	} } &lt;/pre&gt; &lt;p&gt;(No, you can't put Main() as a global function - global functions don't exist  in C#.)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.8"&gt;1.8 Is C# object-oriented?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, C# is an OO language in the tradition of Java and C++.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="1.9"&gt;1.9 Does C# have its own class library?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Not exactly. In common with all .NET languages (e.g. VisualBasic.NET,  JScript.NET) C# has access to the .NET class library. C# does not have its own  class library.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="2."&gt;2. Basic types&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="2.1"&gt;2.1 What standard types does C# supply?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;C# supports a very similar range of basic types to C++, including int, long,  float, double, char, string, arrays, structs and classes. However, don't assume  too much. The names may be familiar, but some of the details are different. For  example, a long is 64 bits in C#, whereas in C++ the size of a long depends on  the platform (typically 32 bits on a 32-bit platform, 64 bits on a 64-bit  platform). Also classes and structs are almost the same in C++ - this is not  true for C#.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="2.2"&gt;2.2 Is it true that all C# types derive from a common base  class?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes and no. All types can be treated as if they derive from &lt;b&gt;object&lt;/b&gt;  (System.Object), but in order to treat an instance of a value type (e.g. int,  float) as &lt;b&gt;object&lt;/b&gt;-derived, the instance must be converted to a reference  type using a process called 'boxing'. In theory a developer can forget about  this and let the run-time worry about when the conversion is necessary, but in  reality this implicit conversion can have side-effects that may trip up the  unwary.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="2.3"&gt;2.3 So this means I can pass an instance of a value type to a  method that takes an object as a parameter?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes. For example:&lt;/p&gt;&lt;pre class="code"&gt;class CApplication { 	public static void Main() 	{  		int x = 25;  		string s = "fred";  		 		DisplayMe( x );  		DisplayMe( s );  	}  	 	static void DisplayMe( object o )  	{  		System.Console.WriteLine( "You are {0}", o );  	} }  &lt;/pre&gt; &lt;p&gt;This would display:&lt;/p&gt;&lt;pre class="code"&gt;You are 25 You are fred &lt;/pre&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;h3&gt;&lt;a name="2.4"&gt;2.4 What are the fundamental differences between value types and  reference types?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;C# divides types into two categories - &lt;em&gt;value&lt;/em&gt; types and  &lt;em&gt;reference&lt;/em&gt; types. Most of the basic intrinsic types (e.g. int, char) are  value types. Structs are also value types. Reference types include classes,  interfaces, arrays and strings. The basic idea is straightforward - an instance  of a value type represents the actual data (stored on the stack), whereas an  instance of a reference type represents a pointer or reference to the data  (stored on the heap).&lt;/p&gt; &lt;p&gt;The most confusing aspect of this for C++ developers is that C# has  predetermined which types will be represented as values, and which will be  represented as references. A C++ developer expects to take responsibility for  this decision. &lt;/p&gt; &lt;p&gt;For example, in C++ we can do this:&lt;/p&gt;&lt;pre class="code"&gt;int x1 = 3;		// x1 is a value on the stack int *x2 = new int(3)	// x2 is a reference to a value on the heap &lt;/pre&gt; &lt;p&gt;but in C# there is no control:&lt;/p&gt;&lt;pre class="code"&gt;int x1 = 3;		// x1 is a value on the stack int x2 = new int();  x2 = 3;		// x2 is also a value on the stack! &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="2.5"&gt;2.5 Okay, so an &lt;em&gt;int&lt;/em&gt; is a value type, and a  &lt;em&gt;class&lt;/em&gt; is a reference type. How can &lt;em&gt;int&lt;/em&gt; be derived from  &lt;em&gt;object&lt;/em&gt;?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;It isn't, really. When an &lt;strong&gt;int&lt;/strong&gt; is being used as an  &lt;strong&gt;int&lt;/strong&gt;, it is a value (on the stack). However, when it is being  used as an &lt;strong&gt;object&lt;/strong&gt;, it is a reference to an integer value on the  heap. In other words, when you treat an &lt;strong&gt;int&lt;/strong&gt; as an object, the  runtime automatically converts the &lt;strong&gt;int&lt;/strong&gt; value to an  &lt;strong&gt;object&lt;/strong&gt; reference. This process is called boxing. The conversion  involves copying the contents of the &lt;strong&gt;int&lt;/strong&gt; from the stack to the  heap, and creating an &lt;strong&gt;object&lt;/strong&gt; instance which refers to it.  Unboxing is the reverse process - the object is converted back to a stack-based  value.&lt;/p&gt;&lt;pre class="code"&gt;int x = 3;		// new int value 3 on the stack object objx = x;	// new int on heap, set to value 3 - still have x=3 on stack int y = (int)objx;	// new value 3 on stack, still got x=3 on stack and objx=3 on heap &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="2.6"&gt;2.6 C# uses references instead of pointers. Are C# references  the same as C++ references?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Not quite. The basic idea is the same, but one significant difference is that  C# references can be &lt;b&gt;null&lt;/b&gt;. So you cannot rely on a C# reference pointing  to a valid object. If you try to use a null reference, a NullReferenceException  is thrown.  &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;For example, look at the following method:&lt;/p&gt;&lt;pre class="code"&gt;void displayStringLength( string s ) { 	Console.WriteLine( "String is length {0}", s.Length ); }		 &lt;/pre&gt; &lt;p&gt;The problem with this method is that it will throw a NullReferenceException  if called like this:&lt;/p&gt;&lt;pre class="code"&gt;string s = null; displayStringLength( s ); &lt;/pre&gt; &lt;p&gt;Of course for some situations you may deem a NullReferenceException to be a  perfectly acceptable outcome, but in this case it might be better to re-write  the method like this:&lt;/p&gt;&lt;pre class="code"&gt;void displayStringLength( string s ) { 	if( s == null ) 		Console.WriteLine( "String is null" ); 	else 		Console.WriteLine( "String is length {0}", s.Length ); }		 &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="3."&gt;3. Classes and structs&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="3.1"&gt;3.1 Structs are largely redundant in C++. Why does C# have  them?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;In C++, a struct and a class are pretty much the same thing. The only  difference is the default visibility level (public for structs, private for  classes). However, In C# structs and classes are very different. In C#, structs  are &lt;em&gt;value&lt;/em&gt; types (stored on the stack), whereas classes are  &lt;em&gt;reference&lt;/em&gt; types (stored on the heap). Also structs cannot inherit from  structs or classes, though they can implement interfaces. Structs cannot have  destructors.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.2"&gt;3.2 Does C# support multiple inheritance (MI)?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;C# supports multiple inheritance of &lt;em&gt;interfaces&lt;/em&gt;, but not of classes.  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.3"&gt;3.3 Is a C# interface the same as a C++ abstract class?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No, not quite. An abstract class in C++ cannot be instantiated, but it can  (and often does) contain implementation code and/or data members. A C# interface  cannot contain any implementation code or data members - it is simply a group of  method names &amp;amp; signatures. A C# interface is more like a COM interface than  a C++ abstract class. &lt;/p&gt; &lt;p&gt;The other major difference is that a C# class can inherit from only one class  (abstract or not), but can implement multiple interfaces.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.4"&gt;3.4 Are C# constructors the same as C++ constructors?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Very similar.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.5"&gt;3.5 Are C# destructors the same as C++ destructors?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No! They look the same but they're very different. First of all, a C#  destructor isn't guaranteed to be called at any particular time. In fact it's  not guaranteed to be called at all. Truth be told, a C# destructor is really  just a Finalize method in disguise. In particular, it is a Finalize method with  a call to the base class Finalize method inserted. So this:&lt;/p&gt;&lt;pre class="code"&gt;class CTest { 	~CTest() 	{ 		System.Console.WriteLine( "Bye bye" ); 	} } &lt;/pre&gt; &lt;p&gt;is really this:&lt;/p&gt;&lt;pre class="code"&gt;class CTest { 	protected override void Finalize()  	{ 		System.Console.WriteLine( "Bye bye" );  		base.Finalize(); 	} } &lt;/pre&gt; &lt;p&gt;If you don't believe me, try putting a Finalize method &lt;em&gt;and&lt;/em&gt; a  destructor in a C# class and watch the compiler sheepishly confess its  deceit.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.6"&gt;3.6 If C# destructors are so different to C++ destructors, why  did MS use the same syntax?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Because they're evil, and they want to mess with your mind. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.7"&gt;3.7 What is a static constructor?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;A constructor for a class, rather than instances of a class. The static  constructor is called when the class is loaded.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.8"&gt;3.8 Are all methods virtual in C#?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No. Like C++, methods are non-virtual by default, but can be marked as  virtual. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="3.9"&gt;3.9 How do I declare a pure virtual function in C#?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Use the abstract modifier on the method. The class must also be marked as  abstract (naturally). Note that abstract methods cannot have an implementation  (unlike pure virtual C++ methods).&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="4."&gt;4. Exceptions&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="4.1"&gt;4.1 Can I use exceptions in C#?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, in fact exceptions are the recommended error-handling mechanism in C#  (and in .NET in general). Most of the .NET framework classes use exceptions to  signal errors.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.2"&gt;4.2 What types of object can I throw as exceptions?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Only instances of the System.Exception classes, or classes derived from  System.Exception. This is in sharp contrast with C++ where instances of almost  any type can be thrown.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.3"&gt;4.3 Can I define my own exceptions?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, as long as you follow the rule that exceptions derive from  System.Exception. More specifically, MS recommend that user-defined exceptions  inherit from System.ApplicationException (which is derived from  System.Exception).&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.4"&gt;4.4 Are there any standard exceptions that I can  re-use?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, and some of them loosely correspond to standard COM HRESULTs. The table  below shows a mapping from HRESULTs to .NET (and therefore C#) exceptions:&lt;/p&gt; &lt;p&gt; &lt;table border="1" width="75%" cellpadding="5"&gt; &lt;tbody&gt; &lt;tr valign="top"&gt; &lt;td&gt;&lt;strong&gt;HRESULT&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;.NET EXCEPTION&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;E_INVALIDARG&lt;/td&gt; &lt;td&gt;&lt;em&gt;ArgumentOutOfRangeException&lt;/em&gt;, or the more general  &lt;em&gt;ArgumentException&lt;/em&gt;. Alternatively &lt;em&gt;FormatException&lt;/em&gt; if a supplied  parameter is not the correct format - e.g. a URL is specified as htp:// instead  of http://&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;E_POINTER&lt;/td&gt; &lt;td&gt;&lt;em&gt;ArgumentNullException&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;E_NOTIMPL&lt;/td&gt; &lt;td&gt;&lt;em&gt;NotImplementedException&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;E_UNEXPECTED&lt;/td&gt; &lt;td&gt;Some may consider &lt;em&gt;InvalidOperationException &lt;/em&gt;to be equivalent.  &lt;em&gt;InvalidOperationException&lt;/em&gt; is normally used to indicate that an object  cannot perform the requested operation because it is not in a suitable state to  do so.&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt;E_OUTOFMEMORY&lt;/td&gt; &lt;td&gt;&lt;em&gt;OutOfMemoryException&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt; &lt;p&gt;Other standard exceptions that you might want to re-use are  &lt;em&gt;IndexOutOfRangeException&lt;/em&gt; and &lt;em&gt;ArithmeticException&lt;/em&gt; .&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.5"&gt;4.5 Does the System.Exception class have any cool  features?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes - the feature which stands out is the StackTrace property. This provides  a call stack which records where the exception was thrown from. For example, the  following code:&lt;/p&gt;&lt;pre class="code"&gt;using System;  class CApp  {   	public static void Main()  	{  		try  		{  			f();  		}  		catch( Exception e )  		{  			Console.WriteLine( "System.Exception stack trace = \n{0}", e.StackTrace );  		} 	}   	static void f()  	{  		throw new Exception( "f went pear-shaped" );  	}  } &lt;/pre&gt; &lt;p&gt;produces this output:&lt;/p&gt;&lt;pre class="code"&gt;System.Exception stack trace =  	at CApp.f()  	at CApp.Main() &lt;/pre&gt; &lt;p&gt;Note, however, that this stack trace was produced from a debug build. A  release build may optimise away some of the method calls which could mean that  the call stack isn't quite what you expect.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.6"&gt;4.6 When should I throw an exception?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;This is the subject of some debate, and is partly a matter of taste. However,  it is accepted by many that exceptions should be thrown only when an  'unexpected' error occurs. How do you decide if an error is expected or  unexpected? This is a judgement call, but a straightforward example of an  expected error is failing to read from a file because the seek pointer is at the  end of the file, whereas an example of an unexpected error is failing to  allocate memory from the heap.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="4.7"&gt;4.7 Does C# have a 'throws' clause?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No, unlike Java, C# does not require (or even allow) the developer to specify  the exceptions that a method can throw.  &lt;/p&gt;&lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="5."&gt;5. Run-time type information&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="5.1"&gt;5.1 How can I check the type of an object at runtime?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;You can use the &lt;strong&gt;is&lt;/strong&gt; keyword. For example:&lt;/p&gt;&lt;pre class="code"&gt;using System;   class CApp { 	public static void Main() 	{  		string s = "fred";  		long i = 10;   		Console.WriteLine( "{0} is {1}an integer", s, (IsInteger(s) ? "" : "not ") );  		Console.WriteLine( "{0} is {1}an integer", i, (IsInteger(i) ? "" : "not ") );  	} 	 	static bool IsInteger( object obj ) 	{  		if( obj is int || obj is long ) 			return true;  		else  			return false; 	} }  &lt;/pre&gt; &lt;p&gt;produces the output:&lt;/p&gt;&lt;pre class="code"&gt;fred is not an integer  10 is an integer &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="5.2"&gt;5.2 Can I get the name of a type at runtime?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, use the GetType method of the object class (which all types inherit  from). For example:&lt;/p&gt;&lt;pre class="code"&gt;using System;   class CTest { 	class CApp  	{ 		public static void Main() 		{  			long i = 10;  			CTest ctest = new CTest();   			DisplayTypeInfo( ctest );  			DisplayTypeInfo( i );  		} 		 		static void DisplayTypeInfo( object obj )  		{  			Console.WriteLine( "Type name = {0}, full type name = {1}", obj.GetType(), obj.GetType().FullName );  		} 	} } &lt;/pre&gt; &lt;p&gt;produces the following output:&lt;/p&gt;&lt;pre class="code"&gt;Type name = CTest, full type name = CTest  Type name = Int64, full type name = System.Int64 &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="6."&gt;6.  Advanced language features&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="6.1"&gt;6.1 What are delegates?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;A delegate is a class derived from System.Delegate. However the language has  a special syntax for declaring delegates which means that they don't look like  classes. A delegate represents a method with a particular signature. An instance  of a delegate represents a method with a particular signature on a particular  object (or class in the case of a static method). For example:&lt;/p&gt;&lt;pre class="code"&gt;using System; delegate void Stereotype();  class CAmerican  { 	public void BePatriotic()  	{  		Console.WriteLine( "... &lt;gulp&gt; ... God bless America."); 	} }   class CBrit { 	public void BeXenophobic() 	{ 		Console.WriteLine( "Bloody foreigners ... " ); 	} }  class CApplication {  	public static void RevealYourStereotype( Stereotype[] stereotypes ) 	{  		foreach( Stereotype s in stereotypes )  			s(); 	} 	 	public static void Main()  	{ 		CAmerican chuck = new CAmerican();  		CBrit edward = new CBrit();   		// Create our list of sterotypes. 		Stereotype[] stereotypes = new Stereotype[2]; 		stereotypes[0] = new Stereotype( chuck.BePatriotic ); 		stereotypes[1] = new Stereotype( edward.BeXenophobic ); 		 		// Reveal yourselves! 		RevealYourStereotype(stereotypes );  	}  } &lt;/gulp&gt;&lt;/pre&gt; &lt;p&gt;This produces the following result:&lt;/p&gt;&lt;pre class="code"&gt;... &lt;gulp&gt;... God bless America. Bloody foreigners ... &lt;/gulp&gt;&lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="6.2"&gt;6.2 Are delegates just like interfaces with a single  method?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Conceptually delegates can be used in a similar way to an interface with a  single method. The main practical difference is that with an interface the  method name is fixed, whereas with a delegate only the signature is fixed - the  method name can be different, as shown in the example above.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="6.3"&gt;6.3 What is the C# equivalent of QueryInterface?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;The &lt;strong&gt;as&lt;/strong&gt; keyword. For example:&lt;/p&gt;&lt;pre class="code"&gt;using System;   interface IPerson {  	string GetName();  }  interface IPerson2 : IPerson  {  	int GetAge();  }   class CPerson : IPerson  {  	public CPerson( string name ) 	{ 		m_name = name; 	}  	 	// IPerson  	public string GetName() 	{ 		return m_name; 	} 	  	private string m_name;  }  class CPerson2 : IPerson2 {  	public CPerson2( string name, int age )  	{  		m_name = name;  		m_age = age;  	} 	 	// IPerson2  	public string GetName() { return m_name; }  	public int GetAge() { return m_age; }  	private string m_name; private int m_age; }   public class CApp  { 	public static void Main() 	{  		CPerson bob = new CPerson( "Bob" );  		CPerson2 sheila = new CPerson2( "Sheila", 24 );  		 		DisplayAge( bob ); 		DisplayAge( sheila );  	} 	 	static void DisplayAge( IPerson person ) 	{ 		IPerson2 person2 = person as IPerson2;   // QueryInterface lives on !!!  		if( person2 != null ) 			Console.WriteLine( "{0} is {1} years old.", person2.GetName(), person2.GetAge() );  		else  			Console.WriteLine( "Sorry, don't know {0}'s age.", person.GetName() );  	}  } &lt;/pre&gt; &lt;p&gt;Running the program produces the following output:&lt;/p&gt;&lt;pre class="code"&gt;Sorry, don't know Bob's age. Sheila is 24 years old. &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="7."&gt;7. It doesn't work like that in C++ ...&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="7.1"&gt;7.1 I 'new'-ed an object, but how do I delete it?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;You can't. You are not allowed to call the destructor explicitly, and no  delete operator is provided. Don't worry, the garbage collector will destroy  your object .... eventually .... probably .... :-)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="7.2"&gt;7.2 I tried to create an object on the stack, but the C#  compiler complained. What's going on?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Unlike C++, you cannot create instances of classes on the stack. Class  instances always live on the heap and are managed by the garbage collector.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="7.3"&gt;7.3 I defined a destructor, but it never gets called.  Why?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;A C# destructor is really just an implementation of Finalize, and the runtime  doesn't guarantee to call Finalize methods. In particular, the runtime doesn't  usually bother calling Finalize methods for objects that are still alive when  you exit an application. However, you can politely ask it to reconsider that  approach by calling the GC.RequestFinalizeOnShutdown() method.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="7.4"&gt;7.4 Most of the C# basic types have the same names as C++ basic  types? Are they the same?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;No. A char in C# is equivalent to a wchar_t in C++. All characters (and  strings, obviously) are Unicode in C#. Integral values in C# are concrete sizes,  unlike C++ (where size depends on processor). For example, a C# int is 32 bits,  whereas a C++ int is normally 32 bits on a 32-bit processor and 64 bits on a  64-bit processor. A C# long is 64 bits.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="8."&gt;8. Miscellaneous&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="8.1"&gt;8.1 String comparisons using == seem to be case-sensitive? How  do I do a case-insensitive string comparison?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Use the String.Compare function. Its third parameter is a boolean which  specifies whether case should be ignored or not.&lt;/p&gt;&lt;pre class="code"&gt;"fred" == "Fred"	// false System.String.Compare( "fred", "Fred", true )	// true &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="8.2"&gt;8.2 I've seen some string literals which use the @ symbol, and  some which don't. What's that all about?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;The @ symbol before a string literal means that escape sequences are ignored.  This is particularly useful for file names, e.g.&lt;/p&gt;&lt;pre class="code"&gt;string fileName = "c:\\temp\\test.txt" &lt;/pre&gt; &lt;p&gt;versus:&lt;/p&gt;&lt;pre class="code"&gt;string fileName = @"c:\temp\test.txt" &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="8.3"&gt;8.3 Does C# support a variable number of arguments?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes, using the &lt;em&gt;params&lt;/em&gt; keyword. The arguments are specified as a list  of arguments of a specific type, e.g. &lt;em&gt;int&lt;/em&gt;. For ultimate flexibility,  the type can be &lt;em&gt;object&lt;/em&gt;. The standard example of a method which uses  this approach is System.Console.WriteLine().&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="8.4"&gt;8.4 How can I process command-line arguments?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Like this:&lt;/p&gt;&lt;pre class="code"&gt;using System;  class CApp { 	public static void Main( string[] args ) 	{ 		Console.WriteLine( "You passed the following arguments:" ); 		foreach( string arg in args ) 			Console.WriteLine( arg ); 	} } &lt;/pre&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="8.5"&gt;8.5 Does C# do array bounds checking?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Yes. An &lt;em&gt;IndexOutOfRange&lt;/em&gt; exception is used to signal an error.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="8.6"&gt;8.6 How can I make sure my C# classes will interoperate with  other .NET languages?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Make sure your C# code conforms to the Common Language Subset (CLS). To help  with this, add the [assembly:CLSCompliant(true)] global attribute to your C#  source files. The compiler will emit an error if you use a C# feature which is  not CLS-compliant.  &lt;/p&gt;&lt;p&gt; &lt;/p&gt; &lt;h2&gt;&lt;a name="9."&gt;9. Resources&lt;/a&gt;&lt;/h2&gt; &lt;h3&gt;&lt;a name="9.1"&gt;9.1 Where can I find out more about C#?&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;The Microsoft .NET homepage is at &lt;a href="http://www.microsoft.com/net/" target="_top"&gt;http://www.microsoft.com/net/&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Robert Scoble has compiled an extremely comprehensive list of .NET on-line  resources at &lt;a href="http://www.devx.com/dotnet/resources/" target="_top"&gt;http://www.devx.com/dotnet/resources/&lt;/a&gt;  &lt;/p&gt;&lt;p&gt;There is a very snazzy site dedicated to C# at &lt;a href="http://csharpindex.com/" target="_top"&gt;http://csharpindex.com/&lt;/a&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a name="9.2"&gt;9.2 Sample code and utilities&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Peter Drayton has some .NET utilities (with C# source) at &lt;a href="http://www.razorsoft.net/" target="_top"&gt;http://www.razorsoft.net/&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5854982658058152331?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5854982658058152331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5854982658058152331' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5854982658058152331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5854982658058152331'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/c-frequently-asked-questions-for-c.html' title='C# Frequently Asked Questions for C++ programmers'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7093924678003551837</id><published>2008-10-23T03:28:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>FileShare Server / Client </title><content type='html'>&lt;title&gt;Welcome to Learn C# - the easy way , by Saurabh Nandu.&lt;/title&gt;&lt;link href="fileshare_files/mystyle.css" type="text/css" rel="stylesheet"&gt;&lt;h3 class="newsheading" align="center"&gt;&lt;br /&gt;&lt;/h3&gt; &lt;table border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="10"&gt;&lt;/td&gt; &lt;td width="97%"&gt; &lt;p align="justify"&gt;   &lt;span style="font-family:Arial;font-size:85%;"&gt; I was on a look out for some  concrete example on Sockets. I found a very good example of a POP and SMTP  server written by my friend Pramod Singh. I have used the Logic from his example  to Build this Example. Thank You Pramod !! This program is sort of a Peer to  Peer Application where there is transfer of files between two peers.&lt;br /&gt;    This  example uses the "System.Net.Sockets" Namespace to create a Client / Server. The  server acts as a File Sharing Server, it listens for multiple clients to connect  to it. The Clients have a option to either Download any of the Files available  with the server for download. Also the Clients can Upload files to the Server  (if the Server allows it).&lt;br /&gt;    The example uses a Command based talking  between them i.e. The Server sends a Command to the Client , the Client decodes  the Command and acts according to the command. If the Client Sends a Command,  the Server acts according to the command sent by the server. Note all command I  have used here have 4 characters and in Capital letters. &lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;For Example this is the procedure of  connection:&lt;br /&gt;1) Server starts to listen on the given port.&lt;br /&gt;2) Client  connects to the Server on the given port.&lt;br /&gt;3) Server sends a "CONN Welcome to  File Share Server" message.&lt;br /&gt;4) The Client decodes the message and sends a  "USER guest" message to the server.&lt;br /&gt;5) Server reads the User Name adds it to  the User ListBox and Sends&lt;br /&gt; "LIST  c:\FileShare\server\download\mydown.txt@c:\FileShare\server\download\myfile.exe"&lt;br /&gt;i.e.  a list of al the files it has for download.&lt;br /&gt;6) The client updates its  Download File ListBox with the List of files sent by the server, and exists the  Thread.&lt;br /&gt;&lt;br /&gt;Steps Occurring while Downloading File by the Client&lt;br /&gt;1) Client  Sends a "DOWN myfile.exe" command to the server.&lt;br /&gt;2) The Server has 2 options  here&lt;br /&gt;   a) If File Name is Valid an Server permits Download then the server  sends&lt;br /&gt;       "SIZE 35346" (the SIZE command with the size of the File  Requested for download.&lt;br /&gt;   b) If the File Name is incorrect or the Server  does not allow downloading the server sends&lt;br /&gt;      "NOPE FileNotFound" or  "NOPE Download not Allowed!" .&lt;br /&gt;3) If the NOPE command is Received then the  client sends a "OHHH No Problem"&lt;br /&gt;4) If the SIZE command is received then the  client sends a "SEND myfile.exe" to indicate the server to start sending the  file.&lt;br /&gt;5) On Receiving a "SEND" command the Server opens a stream to the File  and sends the File over the socket to the client.&lt;br /&gt;6) After successful receipt  of file the server sends a "RECD File!!" command.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Steps Occurring while Uploading File to  the Server&lt;br /&gt;1) Client sends a "&lt;a href="mailto:UPFL%20myUpload.txt@65345"&gt;UPFL  myUpload.txt@65345&lt;/a&gt;" i.e. it sends the File Name and the Size of the File  .&lt;br /&gt;2) If the Server does not allow Upload it sends a "NOPE Server upload  Disabled" ;&lt;br /&gt;3) Otherwise a "SEND File" command is sent.&lt;br /&gt;4) On getting a  "SEND" command the client opens a stream  to the file and sends it over the  Socket to the Server.&lt;br /&gt;5) After successful receipt of file the server sends a  "RECD File Received Properly" command to the Client.&lt;br /&gt;&lt;br /&gt;Execution :&lt;br /&gt;1)  Run the FileShareServer.exe first to start the server .(The server by default  listens for connection on port 4455).&lt;br /&gt;2) Run the FileShareClient.exe which  will connect to the server.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7093924678003551837?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7093924678003551837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7093924678003551837' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7093924678003551837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7093924678003551837'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/fileshare-server-client.html' title='FileShare Server / Client '/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-6624960935419173538</id><published>2008-10-23T03:23:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>.NET FAQ</title><content type='html'>&lt;p align="justify"&gt;  &lt;span style="font-family:Arial;font-size:85%;"&gt;In this section I will try to answer some of the most  Basic question that may arise in the Minds of New Developers about the .NET  Platform. Please remember that these answers are my Interpretations of the .NET  platform and may be not be exactly right.&lt;/span&gt;&lt;/p&gt; &lt;h3 align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;&lt;i&gt;1) .NET Platform  FAQ&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;1 What is .NET Platform?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt; According to Microsoft, .NET is a "revolutionary new  platform, built on open Internet protocols and standards, with tools and  services that meld computing and communications in new ways".&lt;br /&gt;  A simpler way  of saying that would be that the .NET Platform is a new Runtime Environment for  developing and running applications which are easier to build, deploy and scale.  Also it features a a Common Language Specification which helps to solve the  interoperability issue. Also components written in one programming language can  be used by other programming language.   &lt;/span&gt;&lt;/p&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;2 How do I develop in .NET ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Get the .NET SDK from Microsoft. The .NET SDK  contains command-line compilers and utilities which can be used to build .NET  apps. Visual Studio (called Visual Studio 7 or Visual Studio.NET) also is fully  supportive to  .NET development.&lt;/span&gt;&lt;/p&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;3 Where can I download the .NET SDK &amp;amp;  Visual  Studio 7?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can download the .NET SDK from &lt;a href="http://msdn.microsoft.com/net" target="_top"&gt;http://msdn.microsoft.com/net&lt;/a&gt;  (110Mb). You can also order CD's  of Visual Studio 7 beta from Microsoft (Visual Studio 7 contains the .NET  SDK).&lt;/span&gt;&lt;/p&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;4 What are the key technologies within  .NET?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;ASP.NET, CLR (Common Language Runtime), C# (a new  Java-like language), Visual Basic .NET, Managed C++, Visual Foxpro .NET, SOAP,  XML, ADO+, multi-language support (Eiffel, COBOL etc)&lt;/span&gt;&lt;/p&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;5 What platforms does .NET run on?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;This version of .NET  runs on Win95/98/ME &amp;amp;  Windows NT/2000. Please remember to install Personal Web Server on Win95/98/ME  or IIS 5.0 on WinNT/2000 which is needed to run ASP.NET before installing the  .NET SDK. &lt;/span&gt;&lt;/p&gt; &lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;6 What languages does .NET support?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;At present MS provides compilers for C#, C++, VB and  JScript. Other vendors have announced that they intend to develop .NET compilers  for languages such as COBOL, Eiffel, Perl and Python.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;i&gt;2 C# FAQ&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;1 What is C# ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;   C# can be defined as, "C# is a simple, modern,  object oriented, and type-safe programming language derived from C and C++. C#  (pronounced C sharp) is firmly planted in the C and C++ family tree of  languages, and will immediately be familiar to C and C++ programmers. C# aims to  combine the high productivity of Visual Basic and the raw power of C++."&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;2 Is C# C+++ ( a new version of C++)?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;   C# is not a upgrade to C++. C# is a totally new  Object oriented programming language. You could say its much more easier and  Object oriented than C/ C++.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;3 Does C# support RAD like Visual Basic  ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Yep C# is a RAD (Rapid Application Development)  Language like Visual Basic. It supports the Drag- Drop and Build features of  Visual Basic.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;4 Where can I get C# Compiler ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  The C# compiler is not distributed as a separate  entity yet. You will need to download the .NET SDK (110 Mb) from &lt;a href="http://msdn.microsoft.com/net"&gt;http://msdn.microsoft.com/net&lt;/a&gt; . The SDK  contains the C#, VB.NET, JScript Compilers and full documentation and its  Free.   &lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;5 How can I start learning C# ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  First download the .NET SDK. The SDK contains  compilers, documentation, code samples and Quick start pages to help you learn  faster. You can also visit many web sites which provide tutorials and articles  on .NET. &lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;6 Where can I get information on Books on  C#?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Check out &lt;a href="http://www.dotnetbooks.com/"&gt;http://www.dotnetbooks.com/&lt;/a&gt; they have a  listing of all books available for the .NET platform.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;7 Is C# easy to learn ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  If you are a Java programmer then you will find it  very easy to migrate to C# (I did migrate from Java to C#). Also if you are a C  / C++ programmer then you will find much similar syntax of C#.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;8 Is C# platform Independent ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  The answer to this is a bit tactical. C#  applications cannot run without the .NET runtime. As present the .NET platform  has been released for Win95/98/ME and Win NT/2000. MS plans to release the .NET  runtime for other platforms soon . Now if a .NET runtime has been released for  your platform then all the .NET programs will run on your platform. This is  quite similar to the working of SUN Java which is considered to be Platform  Independent. In the case of Sun Java you need to install a Java Virtual Machine  on your Platform to run Java programs. If your platform does not have a Java VM  then it cannot run Java programs. Hence you can consider the concept Java VM  similar to the .NET Runtime Environment (not literally ).  &lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;9 I have written programs in C# how can I run it on  my Clients Machine ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Till the time a separate runtime environment is  released for .NET, you will have to install the Full .NET SDK on every machine  you can to run you programs.  &lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;10 Is C# better than Java ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  I will not fall in the heated debate that's going  on on this topic. You will find many sites which have discussion boards running  for this debate. I will just like to add that Microsoft Products has a very big  market, and MS will surely do all it can to promote its Feature language C#.  Thus there surely will be a demand for C# programmers, now it depends on you to  use Java or C#. &lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;11 Is C# Object Oriented ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Yes, C# is a fully Object Oriented Programming  Language.&lt;/span&gt;  &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;3 ASP.NET &lt;/span&gt;&lt;/b&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;1 Is ASP.NET and ASP+ the same ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Yep ASP+ and ASP.NET are the same thing. First  ASP.NET was called ASP+ since its a upgrade to ASP. Its also called ASP.NET  since its a part of the .NET platform.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;2 Is ASP.NET a upgrade to ASP ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Yes again, ASP.NET is a major upgrade over ASP. It  does have backward support of ASP, but ASP.NET is better managed, and well  developed.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;3 Should all ASP programmers learn ASP.NET  ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  This depends on what kind of ASP programmer you  are. One thing is sure that ASP.NET will overtake ASP in the coming years, but   it will at least take a year for that to happen since to run ASP.NET you need  the .NET platform installed on the server. Till that time ASP will surely be a  more popular choice.&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;4 Does ASP.NET need the .NET Platform  ?  &lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  Since ASP.NET is part of .NET platform you have to  install the .NET SDK first till a separate runtime is released .&lt;/span&gt;  &lt;/p&gt;&lt;h3&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;5 I am a Web Server Admin, How do I install support  for ASP.NET on my server ?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;  You will have to install the .NET SDK. The SDK  contains all the code to convert your server to ASP.NET. Just remember that the  .NET SDK is it its beta stage and can affect your Web Servers  performance.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-6624960935419173538?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/6624960935419173538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=6624960935419173538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/6624960935419173538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/6624960935419173538'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/net-faq.html' title='.NET FAQ'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-554912703734501958</id><published>2008-10-23T03:22:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Introduction to C#</title><content type='html'>C# (pronounced C-Sharp, just like in musical notation) is a new language for  Windows applications, intended as an alternative to the main previous languages,  C++ and VB. Its purpose is twofold:  &lt;ol&gt;&lt;li&gt;It gives access to many of the facilities previously available only in C++,  while retaining some of the simplicity to learn of VB.  &lt;/li&gt;&lt;li&gt;It has been designed specifically with the .NET framework in mind, and hence  is very well structured for writing code that will be compiled for .NET.  &lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;Where Does C# Fit In?&lt;/h3&gt;In programming language terms, if you start from  the lowest level of language available to Windows developer and move up, you'd  see something like this:&lt;br /&gt;&lt;span style="color:darkslateblue;"&gt;&lt;strong&gt;&lt;br /&gt;    »  Assembly Language&lt;br /&gt;        » C, C++&lt;br /&gt;            » C#, J++&lt;br /&gt;                 » VB&lt;br /&gt;                    » VBA, scripting languages &lt;/strong&gt;&lt;/span&gt; &lt;p&gt;As you move down the list you get to languages that are considered  progressively easier to learn and quicker to develop code in, but which leads to  less efficient code. Thus, assembly language will give you absolute  top-performance code, but it's so hard to write and debug that you'll only  really find it used in things like selected subroutines in some high-performance  games, and some software that controls hardware devices where performance is  critical. For most applications requiring good performance, C++ has  traditionally been the language of choice, while if you're developing GUI  applications and want them written quickly, you'll probably opt for VB.  Performance isn't really important for GUI applications because the limiting  factor tends to be how fast the user can click the mouse!  &lt;/p&gt;&lt;p&gt;C# is designed to fill a perceived gap between VB and C++. It's aimed at  developers who would like to be able to write code more easily than is possible  with C++, but without the overhead of VB. (A gap that J++ seems to have largely  failed to satisfy - although it has to be said that there are a lot of  similarities between C# and J++). C# has a syntax that is very similar to C++,  and supports many C++ language features, for example inheritance (though not  multiple inheritance) of classes. For this reason C++ programmers are likely to  find C# easy to learn. By contrast, I suspect for VB programmers, it's likely to  be only marginally easier to learn C# than to learn C++. C# is also heavily  integrated into COM: C# classes are automatically COM objects. (If you don't  want that overhead, you can declare your class as a struct instead).  &lt;/p&gt;&lt;p&gt;A good example of the way C# steers a middle ground between C++ and VB is on  the question of memory management. In VB, the only memory management you ever  need to do is remember to Set your objects to Nothing when you've finished with  them - and the only penalty if you forget to do this is system resources and  memory may be used for slightly longer than necessary. On the other hand, C++  not only gives developers the chance to fine tune exactly what variables occupy  memory for how long (thus potentially leading to highly efficient memory usage)  - it largely &lt;i&gt;requires&lt;/i&gt; them to do so. Which means C++ programs are prone  to memory management bugs, often leading to memory leaks, in a way that can't  really happen in VB.  &lt;/p&gt;&lt;p&gt;C# mostly takes the VB path on memory management - the language itself takes  responsibility for handling it. But unlike VB, in C# if you want to sort out the  memory yourself, you can opt to do so by declaring a section of your code as  'unsafe', and then allocating and deallocating memory in the same way as is done  in C++. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-554912703734501958?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/554912703734501958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=554912703734501958' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/554912703734501958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/554912703734501958'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/introduction-to-c.html' title='Introduction to C#'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2347657120755288678</id><published>2008-07-17T23:02:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>C# developer interview questions</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:ËÎÌå; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:Verdana; 	panose-1:2 11 6 4 3 5 4 4 2 4; 	mso-font-alt:Verdana; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:536871559 0 0 0 415 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} h2 	{margin-top:24.0pt; 	margin-right:0in; 	margin-bottom:19.2pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	mso-outline-level:2; 	font-size:13.0pt; 	font-family:Verdana; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US; 	font-weight:bold;} a:link, span.MsoHyperlink 	{color:#150517; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:#606420; 	text-decoration:underline; 	text-underline:single;} p 	{mso-margin-top-alt:auto; 	margin-right:0in; 	mso-margin-bottom-alt:auto; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:286543376; 	mso-list-template-ids:-466044748;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l1 	{mso-list-id:449709886; 	mso-list-template-ids:-2190628;} @list l1:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l2 	{mso-list-id:837306744; 	mso-list-template-ids:-1690656060;} @list l2:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l3 	{mso-list-id:946042308; 	mso-list-template-ids:1088585560;} @list l3:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l4 	{mso-list-id:966594193; 	mso-list-template-ids:-80597050;} @list l4:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l5 	{mso-list-id:1108550064; 	mso-list-template-ids:122443042;} @list l5:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l6 	{mso-list-id:1895508963; 	mso-list-template-ids:-1752015912;} @list l6:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l7 	{mso-list-id:2034189286; 	mso-list-template-ids:980350526;} @list l7:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;    &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Is it possible to inline assembly or IL in C# code?&lt;span style=""&gt;     &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- No. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in; text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Is it possible to have different access modifiers on the get/set methods of a property? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Is it possible to have a static indexer in C#? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- No. Static indexers are not allowed in C#. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;If I return out of a try/finally in C#, does the code in the finally-clause run? &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to it?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;How does one compare strings in C#?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: -0.25in;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares work: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;How do you specify a custom attribute for the entire assembly (rather than for a class)? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;How do I simulate optional parameters to COM calls?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;- You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters. &lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;2) Which of these string definitions will prevent escaping on backslashes in C#?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;string s = #.n Test string.; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;string s = ..n Test string.; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;string s = @.n Test string.; &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;string s = .n Test string.; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;3) Which of these statements correctly declares a two-dimensional array in C#?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;int[,] myArray;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;int[][] myArray; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;int[2] myArray; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;System.Array[2] myArray; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;4) If a method is marked as &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;" lang="EN"&gt;protected internal&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; who can access it?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Classes that are both in the same assembly and derived from the declaring class. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Only methods that are in the same class as the method in question. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Internal methods can be only be called using reflection. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;Classes within the same assembly, and classes derived from the declaring class.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;5) What is boxing?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 102);" lang="EN"&gt;a) Encapsulating an object in a value type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 102);" lang="EN"&gt;b) Encapsulating a copy of an object in a value type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 102);" lang="EN"&gt;c) Encapsulating a value type in an object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 102);" lang="EN"&gt;d) &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;" lang="EN"&gt;Encapsulating a copy of a value type in an object.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 102);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;6) What compiler switch creates an xml file from the xml comments in the files in an assembly?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;/text &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;/doc&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;/xml &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;/help &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;7) What is a satellite Assembly?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt -0.25in;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;A peripheral assembly designed to monitor permissions requests from an application. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;Any DLL file used by an EXE file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;An assembly containing localized resources for another assembly.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;An assembly designed to alter the appearance or .skin. of an application. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;8) What is a delegate?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;A strongly typed function pointer.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;A light weight thread or process that can call a single method. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;A reference to an object in a different process. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;An inter-process message channel. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;9) How does assembly versioning in .NET prevent DLL Hell?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;The runtime checks to see that only one version of an assembly is on the machine at any one time. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;.NET allows assemblies to specify the name AND the version of any assemblies they need to run.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;The compiler offers compile time checking for backward compatibility. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;It doesn.t. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;11) In the NUnit test framework, which attribute must adorn a test class in order for it to be picked up by the NUnit GUI?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;TestAttribute &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;TestClassAttribute &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;TestFixtureAttribute&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt; text-align: center; text-indent: -0.25in;" align="center"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;NUnitTestClassAttribute &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;12) Which of the following operations can you NOT perform on an ADO.NET DataSet?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-align: center;" align="center"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;1.&lt;span style=""&gt;  &lt;/span&gt;A DataSet can be synchronised with the database. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt 0.25in; text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: green;" lang="EN"&gt;2.&lt;span style=""&gt;  &lt;/span&gt;A DataSet can be synchronised with a RecordSet.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt 0.25in; text-align: center;" align="center"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;3.&lt;span style=""&gt;  &lt;/span&gt;A DataSet can be converted to XML. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt 0.25in; text-align: center;" align="center"&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;&lt;span style=""&gt;        &lt;/span&gt;4.&lt;span style=""&gt;  &lt;/span&gt;You can infer the schema from a DataSet. &lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 14pt; color: black;" lang="EN"&gt;13)&lt;span style=""&gt;   &lt;/span&gt;In Object Oriented Programming, how would you describe encapsulation?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 14pt;" lang="EN"&gt;&lt;span style=""&gt;         &lt;/span&gt;1. The conversion of one type of object to another.&lt;span style=""&gt;                                                               &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 14pt;" lang="EN"&gt;&lt;span style=""&gt;         &lt;/span&gt;2. The runtime resolution of method calls.&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 14pt;" lang="EN"&gt;&lt;span style=""&gt;         &lt;/span&gt;3. The exposition of data&lt;span style=""&gt;                &lt;/span&gt;&lt;span style=""&gt;                                                                                                                                                                                                                                                                &lt;/span&gt;&lt;span style=""&gt;                                                                                                                                                                                                                                       &lt;/span&gt;.&lt;span style=""&gt;        &lt;/span&gt;4.&lt;span style=""&gt;   &lt;/span&gt;The separation of interface and implementation&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: green;"&gt;.&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2347657120755288678?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2347657120755288678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2347657120755288678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2347657120755288678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2347657120755288678'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/07/c-developer-interview-questions.html' title='C# developer interview questions'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7875756393293292161</id><published>2008-07-17T22:56:00.000-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Interview Questions C#</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:ËÎÌå; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Arial Unicode MS"; 	panose-1:2 11 6 4 2 2 2 2 2 4; 	mso-font-charset:128; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1 -369098753 63 0 4129279 0;} @font-face 	{font-family:"\@Arial Unicode MS"; 	panose-1:2 11 6 4 2 2 2 2 2 4; 	mso-font-charset:128; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1 -369098753 63 0 4129279 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Arial Rounded MT Bold"; 	mso-font-alt:Calibri; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} h2 	{mso-style-next:Normal; 	margin:0in; 	margin-bottom:.0001pt; 	line-height:150%; 	mso-pagination:widow-orphan; 	page-break-after:avoid; 	mso-outline-level:2; 	font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US; 	font-weight:normal; 	text-decoration:underline; 	text-underline:single;} h3 	{mso-style-next:Normal; 	margin:0in; 	margin-bottom:.0001pt; 	line-height:150%; 	mso-pagination:widow-orphan; 	page-break-after:avoid; 	mso-outline-level:3; 	font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US; 	font-weight:normal; 	text-decoration:underline; 	text-underline:single;} h4 	{mso-style-next:Normal; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	page-break-after:avoid; 	mso-outline-level:4; 	font-size:14.0pt; 	mso-bidi-font-size:12.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} h5 	{margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-outline-level:5; 	font-size:10.0pt; 	font-family:"Arial Unicode MS"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText 	{margin:0in; 	margin-bottom:.0001pt; 	text-align:center; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	mso-bidi-font-size:12.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US; 	font-weight:bold;} code 	{font-family:"Arial Unicode MS"; 	mso-ascii-font-family:"Arial Unicode MS"; 	mso-fareast-font-family:"Courier New"; 	mso-hansi-font-family:"Arial Unicode MS"; 	mso-bidi-font-family:"Courier New";} span.stylebullet-numberboldchar 	{mso-style-name:stylebullet-numberboldchar;} @page Section1 	{size:8.5in 11.0in; 	margin:27.0pt 27.0pt 27.0pt 27.0pt; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1163470808; 	mso-list-template-ids:-2014909748;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;    &lt;h5 style="margin: 0in 27pt 0.0001pt 45pt; line-height: 150%;"&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-size: 14pt; line-height: 150%; font-family: Arial;"&gt;General Questions&lt;span style=""&gt;                                            &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/h5&gt;&lt;br /&gt;&lt;br /&gt; &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;1.&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Does C# support multiple-inheritance?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;No, use interfaces instead.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;2.     &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Describe the accessibility modifier “protected internal”.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;It is available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;3.     &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s the top .NET class that everything is derived from?&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;System.Object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;4&lt;b&gt;.   &lt;span style=""&gt;  &lt;/span&gt;C&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;an you store multiple data types in System. Array? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;No.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 0.5in; text-indent: 9pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;5.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;How can you sort the elements of the array in descending order?&lt;br /&gt;&lt;span style=""&gt;           &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;By calling Sort() and then Reverse() methods.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;6.  &lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;7.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can multiple catch blocks be executed?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;No. Once the proper catch code fires off, the control is transferred to the finally block.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;8.   &lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What is the role of the DataReader class in ADO.NET connections?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;It returns a read-only dataset from the data source when the command is executed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: &amp;quot;Arial Rounded MT Bold&amp;quot;;"&gt;Class Questions:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b style=""&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;0.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b style=""&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;How do you inherit from a class in C#?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Place a colon and then the name of the base class.&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;1.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can you prevent your class from being inherited by another class?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Yes. The keyword “sealed” will prevent the class from being inherited.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;2.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can you allow a class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Yes. Just leave the class public and make the method sealed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;3.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s an abstract class?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;A class that cannot be instantiated.&lt;span style=""&gt;  &lt;/span&gt;Abstract class is an inherited class that have the methods overridden.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;4.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;When do you absolutely have to declare a class as abstract?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;When at least one of the methods in the class is abstract.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;5.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s an interface class?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;6.  &lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Why can’t you specify the accessibility modifier for methods inside the interface?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;They all must be public.&lt;span style=""&gt;  &lt;/span&gt;Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;7.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can you inherit multiple interfaces?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Yes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;8.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s the difference between an interface and abstract class?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;In an interface no accessibility modifiers are allowed, which is ok in an abstract class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;9.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What is the difference between a Struct and a Class?&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Structs are value-type variables and are thus saved on the stack -&gt; additional overhead but faster retrieval.  Another difference is that structs CANNOT inherit.  (Questions courtesy of Eyal)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Method and Property Questions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;10.   &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s the implicit name of the parameter that gets passed into the set method/property of a class?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Value. The data type of the &lt;i style=""&gt;value&lt;/i&gt; parameter is defined by whatever data type the property is declared as.&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;11.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What does the keyword “virtual” declare for a method or property?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;The method or property can be overridden.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;12.   &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;How is method overriding different from method overloading?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;When overriding a method, you change the behavior of the method for the derived class.&lt;span style=""&gt;  &lt;/span&gt;Overloading a method simply involves having another method with the same name within the class.&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;13.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can you override private virtual methods?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;No. Private methods are not accessible outside the class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;       &lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;       &lt;/span&gt;Original answer:&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;  &lt;/span&gt;No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;14.   &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What are the different ways a method can be overloaded?&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Different parameter data types, different number of parameters, different order of parameters. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;15.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s a delegate?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;A delegate object encapsulates a reference to a method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;16.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s a multicast delegate?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;It’s a delegate that points to and eventually fires off several methods. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;17.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What is a satellite assembly?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;18.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What namespaces are necessary to create a localized application?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;System.Globalization and System.Resources.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;code&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;19.&lt;/span&gt;&lt;/code&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt; &lt;span style=""&gt;  &lt;/span&gt;What is the difference between and &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;XML documentation tag?&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Single line code example and multiple-line code example. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;20.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Is XML case-sensitive? &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Yes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; line-height: 150%; font-family: Arial;"&gt;Debugging and Testing Questions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;21.   &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What debugging tools come with the .NET SDK?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;1.  &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;CorDBG – command-line debugger.&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;2.  &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;DbgCLR – graphic debugger.&lt;span style=""&gt;  &lt;/span&gt;Visual Studio .NET uses the DbgCLR.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;22.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What does the “This” window show in the debugger?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;It points to the object that’s pointed to by this reference. Object’s instance data is shown.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;23.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What does assert() method do?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;24.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What’s the difference between the Debug class and Trace class?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;25.  &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;How do you debug an ASP.NET Web application?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Attach the aspnet_wp.exe process to the DbgClr debugger.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;26.   &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What are three test cases you should go through in unit testing?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;1.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Positive test cases (correct data, correct output).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;2.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Negative test cases (broken or missing data, proper handling).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;3.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Exception test cases (exceptions are thrown and caught properly).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;27.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Can you change the value of a variable while debugging a C# application? &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Yes.&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3 style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; line-height: 150%; font-family: Arial;"&gt;&lt;o:p&gt;&lt;span style="text-decoration: none;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/h3&gt;  &lt;h3 style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; line-height: 150%; font-family: Arial;"&gt;ADO.NET and Database Questions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/h3&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;1.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;SQLServer.NET data provider is high-speed and robust. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access. OLE-DB.NET is not as fastest and efficient as SqlServer.NET.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;2.   &lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Explain ACID rule of thumb for transactions.&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;A transaction must be:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;1.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Atomic &lt;span style=""&gt;        &lt;/span&gt;- &lt;span style=""&gt; &lt;/span&gt;It is one unit of work and does not dependent on previous and following transactions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;2.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Consistent &lt;span style=""&gt;  &lt;/span&gt;- &lt;span style=""&gt; &lt;/span&gt;Data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;3.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Isolated &lt;span style=""&gt;      &lt;/span&gt;- &lt;span style=""&gt; &lt;/span&gt;No transaction sees the intermediate results of the current transaction).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;span style=""&gt;        &lt;/span&gt;4.   &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Durable &lt;span style=""&gt;      &lt;/span&gt;- &lt;span style=""&gt; &lt;/span&gt;The values persist if the data committed even if the system crashes right after.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;3.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What connections does Microsoft SQL Server support?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;4.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What does the &lt;i style=""&gt;Initial Catalog&lt;/i&gt; parameter define in the connection string?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;The database name to connect to. &lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;5.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What is the data provider name to connect to an Access database?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Microsoft.Access.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;6.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What does the &lt;i style=""&gt;Dispose&lt;/i&gt; method do with the connection object?&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Deletes it from the memory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;7.   &lt;/span&gt;&lt;span class="stylebullet-numberboldchar"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;What is a pre-requisite for connection pooling?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;br /&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.&lt;span style=""&gt;  &lt;/span&gt;The connection string must be identical.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 3pt; padding: 0in 0in 1pt; margin-left: 45pt; margin-right: 27pt;"&gt;  &lt;p class="MsoNormal" style="border: medium none ; padding: 0in;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="border: medium none ; padding: 0in;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h4 style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;  &lt;h4 style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style=""&gt;Some More C# Questions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;When you inherit a protected class-level variable, who is it available to? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Classes in the same namespace. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Are private class-level variables inherited? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Describe the accessibility modifier protected internal. &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;How’s method overriding different from overloading? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;5.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What does the keyword virtual mean in the method definition? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;The method can be over-ridden. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;6.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Can you declare the override method static while the original method is non-static? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;7.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;How can you overload a method? &lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;By using&lt;/span&gt;&lt;span style="font-size: 14pt;"&gt; parameters. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;8.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the advantage of using System.Text.StringBuilder over System.String? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;StringBuilder is more efficient in the when lot of manipulations have to be done to the text. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;9.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;How can you sort the elements of the array in descending order? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;By calling Sort() and then Reverse() methods. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;10.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the .NET datatype that allows the retrieval of data by a unique key? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;HashTable. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;11.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s class SortedList underneath? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;A sorted HashTable. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;12.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Will &lt;i&gt;finally&lt;/i&gt; block get executed if the exception had not occurred? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Yes. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;13.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;14.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s a delegate? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;15.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s a multicast delegate? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;It’s a delegate that points to and eventually fires off several methods. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;16.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;How’s the DLL Hell problem solved in .NET? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;17.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s a satellite assembly? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;18.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What namespaces are necessary to create a localized application? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;System.Globalization, System.Resources. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt;"&gt;&lt;span style="font-size: 14pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;19.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the difference between &lt;c&gt; and &lt;code&gt; XML documentation tag? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Single line code example and multiple-line code example. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;20.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What debugging tools come with the .NET SDK? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;21.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;How do you debug an ASP.NET Web application? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Attach the aspnet_wp.exe process to the DbgClr debugger. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;22.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Can you change the value of a variable while debugging a C# application? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Yes. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;23.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the role of the DataReader class in ADO.NET connections? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;It returns a read-only dataset from the data source when the command is executed. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;24.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Which one is trusted and which one is untrusted? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Windows Authentication is trusted because the username and password are checked with the Active Directory; the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;25.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;Why would you use untrusted verificaion? &lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Web Services might use it, as well as non-Windows applications. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;26.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What’s the data provider name to connect to Access database? &lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Microsoft.Access. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;27.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What does dispose method do with the connection object? &lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Deletes it from the memory. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-right: 27pt; margin-left: 45pt; text-indent: 0in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 14pt;"&gt;&lt;span style=""&gt;28.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 14pt;"&gt;What is a pre-requisite for connection pooling?&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 14pt;"&gt;Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;span style="font-size: 14pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 27pt 0.0001pt 45pt;"&gt;&lt;b&gt;&lt;span style="font-size: 14pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7875756393293292161?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7875756393293292161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7875756393293292161' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7875756393293292161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7875756393293292161'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/07/interview-questions-c.html' title='Interview Questions C#'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2030325875885390068</id><published>2008-07-15T22:36:00.000-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Sample chapter on Multithreading from C#: A Programmer's Introduction </title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:ËÎÌå; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:AvantGarde-Demi-OV-EXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Times-Roman-OV-DXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Times-Italic-OV-FXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Times-BoldItalic-OV-SXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:AvantGarde-Bold-OV-PXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Courier-BoldOblique-OV-RXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:modern; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Helvetica-OV-QXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:AvantGarde-Medium-OV-OXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Courier-Bold-OV-VXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:modern; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:AvantGarde-Book-OV-YXAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Courier-Oblique-OV-EYAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:modern; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;} @font-face 	{font-family:Helvetica-BoldOblique-OV-HYAALB; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:SimSun;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;12.1 Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;It would be nice if we could perform one action at a time and perform it well, but that is&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;usually difficult to do. The human body performs a great variety of operations &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;in parallel&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;—&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or, as we will say throughout this chapter, &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;concurrently&lt;/span&gt;&lt;/i&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-BoldItalic-OV-SXAALB; color: black;"&gt;. &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Respiration, blood circulation and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;digestion, for example, can occur concurrently. All the senses—sight, touch, smell, taste&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and hearing—can occur at once. Computers, too, perform operations concurrently. It is&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;common for desktop personal computers to be compiling a program, sending a file to a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;printer and receiving electronic mail messages over a network concurrently.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Ironically, most programming languages do not enable programmers to specify concurrent&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;activities. Rather, programming languages generally provide only a simple set of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;control structures that enable programmers to perform one action at a time, proceeding to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the next action after the previous one has finished. Historically, the type of concurrency that&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;computers perform today generally has been implemented as operating system “primitives”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;available only to highly experienced “systems programmers.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Ada&lt;/st1:place&gt;&lt;/st1:city&gt; programming language, developed by the United States Department of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Defense, made concurrency primitives widely available to defense contractors building&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;military command-and-control systems. However, &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Ada&lt;/st1:place&gt;&lt;/st1:city&gt; has not been widely used in universities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and commercial industry.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The .NET Framework Class Library makes concurrency primitives available to the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;applications programmer. The programmer specifies that applications contain “threads of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;execution,” each thread designating a portion of a program that may execute concurrently&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;with other threads—this capability is called &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;multithreading&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. Multithreading is available to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;all .NET programming languages, including C#, Visual Basic and Visual C++.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Software Engineering Observation 12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;The .NET Framework Class Library includes multithreading capabilities in namespace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;System.Threading&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;. This encourages the use of multithreading among a larger part of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;the applications-programming community. &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 2pt; font-family: Helvetica-OV-QXAALB; color: white;"&gt;12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;We discuss many applications of concurrent programming. When programs download&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;large files, such as audio clips or video clips from the World Wide Web, users do not want&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to wait until an entire clip downloads before starting the playback. To solve this problem,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;we can put multiple threads to work—one thread downloads a clip, and another plays the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;clip. These activities, or &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;tasks&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, then may proceed concurrently. To avoid choppy playback,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;we &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;synchronize &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the threads so that the player thread does not begin until there is a sufficient&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;amount of the clip in memory to keep the player thread busy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Another example of multithreading is C#’s automatic &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;garbage collection&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. C and C++&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;place with the programmer the responsibility of reclaiming dynamically allocated memory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-family: AvantGarde-Demi-OV-EXAALB; color: black;"&gt;Outline&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Demi-OV-EXAALB; color: black;"&gt;12.1 Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Demi-OV-EXAALB; color: black;"&gt;12.2 Thread States: Life Cycle of a Thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Demi-OV-EXAALB; color: black;"&gt;12.3 Thread Priorities and Thread Scheduling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Demi-OV-EXAALB; color: black;"&gt;12.4 Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;Chapter 12 Multithreading 409&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;C# provides a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;garbage-collector thread &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;that reclaims dynamically allocated memory that&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;is no longer needed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Performance Tip 12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;One of the reasons for the popularity of C and C++ over the years was that their memorymanagement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;techniques were more efficient than those of languages that used g*arbage collectors.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;In fact, memory management in C# often is faster than in C or C++.&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="font-size: 7pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 2pt; font-family: Helvetica-OV-QXAALB; color: white;"&gt;12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Good Programming Practice 12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Set an object reference to &lt;/span&gt;&lt;/i&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;null &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;when the program no longer needs that object. This enables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;the garbage collector to determine at the earliest possible moment that the object can be garbage&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;collected. If such an object has other references to it, that object cannot be collected.&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 2pt; font-family: Helvetica-OV-QXAALB; color: white;"&gt;12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Writing multithreaded programs can be tricky. Although the human mind can perform&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;functions concurrently, people find it difficult to jump between parallel “trains of thought.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;To see why multithreading can be difficult to program and understand, try the following&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;experiment: Open three books to page 1 and try reading the books concurrently. Read a few&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;words from the first book, then read a few words from the second book, then read a few&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;words from the third book, then loop back and read the next few words from the first book,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;etc. After this experiment, you will appreciate the challenges of multithreading—switching&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;between books, reading briefly, remembering your place in each book, moving the book&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;you are reading closer so you can see it, pushing books you are not reading aside—and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;amidst all this chaos, trying to comprehend the content of the books!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Performance Tip 12.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;A problem with single-threaded applications is that lengthy activities must complete before&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;other activities can begin. In a multithreaded application, threads can share a processor (or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;set of processors), so that multiple tasks are performed in parallel. &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 2pt; font-family: Helvetica-OV-QXAALB; color: white;"&gt;12.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;12.2 Thread States: Life Cycle of a Thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;At any time, a thread is said to be in one of several &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;thread states &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(illustrated in Fig. 12.1)&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;2&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;This section discusses these states and the transitions between states. Two classes critical&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for multithreaded applications are &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;System.Threading&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;namespace). This section also discusses several methods of classes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;that cause state transitions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A new thread begins its lifecyle in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Unstarted &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;. &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The thread remains in the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Unstarted &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state until the program calls &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Start&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, which places the thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state (sometimes called the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Ready &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Runnable &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state) and immediately returns&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;control to the calling thread. Then the thread that invoked &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Start&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, the newly &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and any other threads in the program execute concurrently.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;1. E. Schanzer, “Performance Considerations for Run-Time Technologies in the .NET Framework,”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;August 2001 &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;&lt;http://msdn.microsoft.com/library/default.asp?url=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;/library/en-us/dndotnet/html/dotnetperftechs.asp&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;2. As this book went to publication, Microsoft changed the names of the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;states to &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, respectively.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;410 Multithreading Chapter 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The highest priority &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state (i.e., begins executing)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;when the operating system assigns a processor to the thread (Section 12.3 discusses thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;priorities). When a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread receives a processor for the first time and becomes a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread, the thread executes its &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate, which specifies the actions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the thread will perform during its lifecyle. When a program creates a new &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, the program&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;specifies the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate as the argument to the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;constructor. The &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate must be a method that returns &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and takes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;no arguments.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(or &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Dead&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;) state when its &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;terminates. Note that a program can force a thread into the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state by calling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Abort &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;on the appropriate &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object. Method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Abort &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;throws a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;ThreadAbortException &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;in the thread, normally causing the thread to terminate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;When a thread is in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state and there are no references to the thread object, the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;garbage collector can remove the thread object from memory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when the thread issues an input/output request. The&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;operating system blocks the thread from executing until the operating system can complete&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the I/O for which the thread is waiting. At that point, the thread returns to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state, so&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;it can resume execution. A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread cannot use a processor even if one is available.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Fig. 12.1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Book-OV-YXAALB; color: rgb(78, 78, 78);"&gt;Thread life cycle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Started&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Running&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;WaitSleepJoin Suspended Stopped Blocked&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Unstarted&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;dispatch&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;(assign a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;processor)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;quantum&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;expiration&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Start&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;I/O completion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Suspend &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Issue I/O request&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Interrupt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;sleep interval expires&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Resume&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Join&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Pulse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;PulseAll&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;complete&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;Chapter 12 Multithreading 411&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;There are three ways in which a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. If a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread encounters code that it cannot execute yet (normally because a condition is not satisfied),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the thread can call &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Wait &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to enter the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Once in this state, a thread returns to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when another thread invokes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Pulse &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;PulseAll&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. Method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Pulse &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;moves the next waiting thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;back to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. Method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;PulseAll &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;moves all waiting threads back to the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread can call &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Sleep &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to enter the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for a period of milliseconds specified as the argument to &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. A sleeping thread returns&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when its designated sleep time expires. Sleeping threads cannot use a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;processor, even if one is available.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Any thread that enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state by calling &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;by calling &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;also leaves the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state and returns to the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state if the sleeping or waiting &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Interrupt &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method is called by another&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread in the program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;If a thread cannot continue executing (we will call this the dependent thread) unless&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;another thread terminates, the dependent thread calls the other thread’s &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Join &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;“join” the two threads. When two threads are “joined,” the dependent thread leaves the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when the other thread finishes execution (enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;If a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Suspend &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method is called, the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Suspended&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Suspended &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread returns to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when another thread in the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;program invokes the Suspended thread’s &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Resume &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;12.3 Thread Priorities and Thread Scheduling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Every thread has a priority in the range between &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadPriority.Lowest &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadPriority.Highest&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. These two values come from the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadPriority&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enumeration (namespace &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;System.Threading&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;). The enumeration consists of the values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Lowest&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;BelowNormal&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, &lt;/span&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Normal&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;AboveNormal &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Highest&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. By default, each&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread has priority &lt;/span&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Normal&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The Windows operating system supports a concept, called &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;timeslicing, &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;that enables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;threads of equal priority to share a processor. Without timeslicing, each thread in a set of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;equal-priority threads runs to completion (unless the thread leaves the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Suspended &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state) before the thread’s peers get a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;chance to execute. With timeslicing, each thread receives a brief burst of processor time,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;called a &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;quantum&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, during which the thread can execute. At the completion of the quantum,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;even if the thread has not finished executing, the processor is taken away from that thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and given to the next thread of equal priority, if one is available.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The job of the thread scheduler is to keep the highest-priority thread running at all&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;times and, if there is more than one highest-priority thread, to ensure that all such threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;execute for a quantum in &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;round-robin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;fashion (i.e., these threads can be timesliced).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Figure 12.2 illustrates the multilevel priority queue for threads. In Fig. 12.2, assuming a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;single-processor computer, threads A and B each execute for a quantum in round-robin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;fashion until both threads complete execution. This means that A gets a quantum of time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to run. Then B gets a quantum. Then A gets another quantum. Then B gets another&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;quantum. This continues until one thread completes. The processor then devotes all its&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;power to the thread that remains (unless another thread of that priority is &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;). Next,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;412 Multithreading Chapter 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread C runs to completion. Threads D, E and F each execute for a quantum in roundrobin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;fashion until they all complete execution. This process continues until all threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;run to completion. Note that, depending on the operating system, new higher-priority&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;threads could postpone—possibly indefinitely—the execution of lower-priority threads.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Such &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;indefinite postponement &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;often is referred to more colorfully as &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;starvation&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A thread’s priority can be adjusted with the &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;property, which accepts&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;values from the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadPriority &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enumeration. If the argument is not one of the valid&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread-priority constants, an &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ArgumentException &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;occurs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A thread executes until it dies, becomes &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for input/output (or some other&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;reason), calls &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, calls &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Join&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, is preempted by a thread of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;higher priority or has its quantum expire. A thread with a higher priority than the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread can become &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(and hence preempt the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread) if a sleeping thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;wakes up, if I/O completes for a thread that &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for that I/O, if either &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Pulse &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;PulseAll &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;is called on an object on which &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;was called, or if a thread to which the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;high-priority thread was &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Join&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;ed completes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Figure 12.3 demonstrates basic threading techniques, including the construction of a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object and using the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;class’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;static &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. The program creates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;three threads of execution, each with the default priority &lt;/span&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Normal&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. Each thread displays&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;a message indicating that it is going to sleep for a random interval of from 0 to 5000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;milliseconds, then goes to sleep. When each thread awakens, the thread displays its name,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;indicates that it is done sleeping, terminates and enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. You will see that&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(i.e., the &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;Main &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;thread of execution&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;) terminates before the application terminates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The program consists of two classes—&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadTester &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(lines 8–41), which creates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the three threads, and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(lines 44–73), which defines a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;containing the actions each thread will perform.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Fig. 12.2 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Book-OV-YXAALB; color: rgb(78, 78, 78);"&gt;Thread-priority scheduling.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Highest&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;AboveNormal&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Normal&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;BelowNormal&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Lowest&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;Ready threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;A B&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;C&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;D E F&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 8pt; font-family: AvantGarde-Book-OV-YXAALB; color: black;"&gt;G&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;Chapter 12 Multithreading 413&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;1 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// Fig. 12.3: ThreadTester.cs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;2 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// Multiple threads printing at different intervals.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;34&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;using &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;5 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;using &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;System.Threading;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;67&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// class ThreadTester demonstrates basic threading concepts&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;8 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;class &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadTester&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;9 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;10 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;static void &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;string&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;[] args )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;11 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;12 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// Create and name each thread. Use MessagePrinter's&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;13 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// Print method as argument to ThreadStart delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;14 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter printer1 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;15 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread thread1 =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;16 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread ( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart( printer1.Print ) );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;17 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1.Name = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;"thread1"&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;18&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;19 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter printer2 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;20 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread thread2 =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;21 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread ( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart( printer2.Print ) );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;22 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2.Name = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;"thread2"&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;24 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter printer3 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;25 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread thread3 =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;26 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread ( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart( printer3.Print ) );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;27 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3.Name = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;"thread3"&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;28&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;29 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Console.WriteLine( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;"Starting threads" &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;30&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;31 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// call each thread's Start method to place each&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;32 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// thread in Started state&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;33 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;34 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;35 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;36&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;37 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Console.WriteLine( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;"Threads started\n" &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;38&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;39 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;} &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// end method &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;40 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;} &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// end class ThreadTester&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;41&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;42 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// Print method of this class used to control threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;43 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;class &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;44 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;45 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;private int &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;46 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;private static &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Random random = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;new &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Random();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;47&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;48 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// constructor to initialize a MessagePrinter object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;49 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;public &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;50 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;51 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// pick random sleep time between 0 and 5 seconds&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;52 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime = random.Next( &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;5001 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;53 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Fig. 12.3 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Book-OV-YXAALB; color: rgb(78, 78, 78);"&gt;Threads sleeping and printing. (Part 1 of 2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;414 Multithreading Chapter 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Objects of class &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(lines 44–73) control the lifecycle of each of the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;three threads class &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadTester&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method creates. Class &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;consists of instance variable &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(line 46), &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;static &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;variable &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;random &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;(line 47),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;a constructor (lines 50–54) and a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method (lines 57–71). Variable &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;stores a random integer value chosen when a new &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object’s constructor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;is called. Each thread controlled by a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object sleeps for the amount of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;time specified by the corresponding &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;54&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;55 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// method Print controls thread that prints messages&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;56 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;public void &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;57 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;58 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// obtain reference to currently executing thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;59 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread current = Thread.CurrentThread;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;60&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;61 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// put thread to sleep for sleepTime amount of time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;62 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Console.WriteLine(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;63 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;current.Name + &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;" going to sleep for " &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;+ sleepTime );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;64&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;65 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread.Sleep ( sleepTime );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;66&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;67 &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// print thread name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;68 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Console.WriteLine( current.Name + &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: rgb(78, 78, 78);"&gt;" done sleeping" &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;69&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;70 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;} &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// end method Print&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;71&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;72 &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;} &lt;/span&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Courier-Oblique-OV-EYAALB; color: black;"&gt;// end class MessagePrinter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Starting threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Threads started&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 going to sleep for 1977&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 going to sleep for 4513&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 going to sleep for 1261&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Starting threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Threads started&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 going to sleep for 1466&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 going to sleep for 4245&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 going to sleep for 1929&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 done sleeping&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Fig. 12.3 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Book-OV-YXAALB; color: rgb(78, 78, 78);"&gt;Threads sleeping and printing. (Part 2 of 2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;Chapter 12 Multithreading 415&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;The &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;constructor (lines 50–54) initializes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;sleepTime &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;random integer from 0 up to, but not including, 5001 (i.e., from 0 to 5000).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;begins by obtaining a reference to the currently executing thread (line&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;60) via class &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;static &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;property &lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Courier-BoldOblique-OV-RXAALB; color: black;"&gt;CurrentThread&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. The currently executing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread is the one that invokes method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. Next, lines 63–64 display a message indicating&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the name of the currently executing thread and stating that the thread is going to sleep&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for a certain number of milliseconds. Note that line 64 uses the currently executing thread’s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Name &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;property to obtain the thread’s name (set in method &lt;/span&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;when each thread is created).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Line 66 invokes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;static Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;to place the thread into the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Wait-&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;SleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. At this point, the thread loses the processor and the system allows another&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread to execute. When the thread awakens, it reenters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state again until the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;system assigns a processor to the thread. When the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object enters the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state again, line 69 outputs the thread’s name in a message that indicates the thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;is done sleeping, and method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;terminates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Class &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadTester&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method (lines 10–39) creates three objects of class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, at lines 14, 19 and 24, respectively. Lines 15–16, 20–21 and 25–26&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;create and initialize three &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;objects. Lines 17, 22 and 27 set each &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;property, which we use for output purposes. Note that each &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s constructor receives&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate as an argument. Remember that a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;specifies the actions a thread performs during its lifecyle. Line 16 specifies that the delegate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;for &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;will be method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;of the object to which &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;refers. When&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state for the first time, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;will invoke &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer1&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method to perform the tasks specified in method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s body. Thus, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;will print its name, display the amount of time for which it will go to sleep, sleep for that&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;amount of time, wake up and display a message indicating that the thread is done sleeping.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;At that point method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;will terminate. A thread completes its task when the method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;specified by a &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate terminates, placing the thread in the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. When &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enter the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state for the first time,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;they invoke the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;methods of &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer2 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer3&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, respectively. Threads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread2 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread3 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;perform the same tasks as &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;thread1 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;by executing the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;methods of the objects to which &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer2 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;printer3 &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;refer (each of which has its&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;own randomly chosen sleep time).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: AvantGarde-Bold-OV-PXAALB; color: rgb(78, 78, 78);"&gt;Testing and Debugging Tip 12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Naming threads helps in the debugging of a multithreaded program. Visual Studio .NET’s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;debugger provides a &lt;/span&gt;&lt;/i&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Helvetica-BoldOblique-OV-HYAALB; color: black;"&gt;Threads &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;window that displays the name of each thread and enables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;you to view the execution of any thread in the program. &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 2pt; font-family: Helvetica-OV-QXAALB; color: white;"&gt;12.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Lines 33–35 invoke each &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Start &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method to place the threads in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state (sometimes called &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;launching a thread&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;). Method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Start &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;returns immediately from&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;each invocation, then line 37 outputs a message indicating that the threads were started, and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Main &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread of execution terminates. The program itself does not terminate, however,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;because there are still threads that are alive (i.e., the threads were &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;and have not&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;reached the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state yet). The program will not terminate until its last thread dies.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;When the system assigns a processor to a thread, the thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;calls the method specified by the thread’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate. In this program, each&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread invokes method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Print &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;of the appropriate &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;MessagePrinter &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;object to perform&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the tasks discussed previously.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: AvantGarde-Medium-OV-OXAALB; color: black;"&gt;416 Multithreading Chapter 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Note that the sample outputs for this program show each thread and the thread’s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;sleep time as the thread goes to sleep. The thread with the shortest sleep time normally&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;awakens first, indicates that it is done sleeping and terminates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-family: AvantGarde-Demi-OV-EXAALB; color: rgb(78, 78, 78);"&gt;12.4 Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Computers perform multiple operations concurrently. Programming languages generally&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;provide only a simple set of control structures that enable programmers to perform just one&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;action at a time and proceed to the next action only after the previous one finishes. The&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;FCL, however, provides the C# programmer with the ability to specify that applications&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;contain threads of execution, where each thread designates a portion of a program that may&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;execute concurrently with other threads. This capability is called multithreading.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;A thread is initialized using the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;class’s constructor, which receives a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate. This delegate specifies the method that contains the tasks a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread will perform. A thread remains in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Unstarted &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state until the thread’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Start&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method is called, which the thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. A thread in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when the system assigns a processor to the thread. The system&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;assigns the processor to the highest-priority &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread. A thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when its &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadStart &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;delegate completes or terminates. A thread is forced into the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Stopped &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when its &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Abort &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method is called (by itself or by another thread). A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Running&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when the thread issues an input/output request. A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread becomes &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;when the I/O it is waiting for completes. A &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Blocked &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread cannot&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;use a processor, even if one is available.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;If a thread needs to sleep, it calls method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Sleep&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;. A thread wakes up when the designated&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;sleep interval expires. If a thread cannot continue executing unless another thread terminates,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the first thread, referred to as the dependent thread, calls the other thread’s &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Join&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method to “join” the two threads. When two threads are joined, the dependent thread leaves&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when the other thread finishes execution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;When a thread encounters code that it cannot yet run, the thread can call &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;until certain actions occur that enable the thread to continue executing. This&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method call puts the thread into the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. Any thread in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state can leave that state if another thread invokes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Interrupt &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;on the&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread in the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. If a thread has called &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Wait&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;, a corresponding&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;call to &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Monitor &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Pulse &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;or &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;PulseAll &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;by another thread in the program&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;will transition the original thread from the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;WaitSleepJoin &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state to the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Started &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;If &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Suspend &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;is called on a thread, the thread enters the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Suspended&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state. A thread leaves the &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Times-Italic-OV-FXAALB; color: black;"&gt;Suspended &lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;state when a separate thread invokes &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Thread &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Resume &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;on the suspended thread.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;Every C# thread has a priority. The job of the thread scheduler is to keep the highestpriority&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;thread running at all times and, if there is more than one highest-priority thread, to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;ensure that all equally high-priority threads execute for a quantum at a time in round-robin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;fashion. A thread’s priority can be adjusted with the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;Priority &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;property, which is&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;assigned an argument from the &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Courier-Bold-OV-VXAALB; color: black;"&gt;ThreadPriority &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Times-Roman-OV-DXAALB; color: black;"&gt;enumeration.&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2030325875885390068?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2030325875885390068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2030325875885390068' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2030325875885390068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2030325875885390068'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/07/sample-chapter-on-multithreading-from-c.html' title='Sample chapter on Multithreading from C#: A Programmer&apos;s Introduction '/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3388116056731938085</id><published>2008-07-15T21:50:00.000-07:00</published><updated>2008-12-22T21:16:10.048-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Threads, Events and Mutexes</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????????????????????????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:Tahoma; 	panose-1:2 11 6 4 3 5 4 4 2 4; 	mso-font-alt:Tahoma; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:1627421319 -2147483648 8 0 66047 0;} @font-face 	{font-family:"Bookman Old Style"; 	panose-1:2 5 6 4 5 5 5 2 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;} @font-face 	{font-family:"Monotype Corsiva"; 	panose-1:3 1 1 1 1 2 1 1 1 1; 	mso-font-charset:0; 	mso-generic-font-family:script; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;} @font-face 	{font-family:"Trebuchet MS"; 	panose-1:2 11 6 3 2 2 2 2 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.ILbase, li.ILbase, div.ILbase 	{mso-style-name:ILbase; 	mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:justify; 	text-justify:inter-ideograph; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:10.0pt; 	font-family:"Bookman Old Style"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.ILprg, li.ILprg, div.ILprg 	{mso-style-name:ILprg; 	mso-style-parent:ILbase; 	mso-style-next:ILbase; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:0in; 	margin-left:.5in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:9.5pt; 	font-family:"Trebuchet MS"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.ILoutput, li.ILoutput, div.ILoutput 	{mso-style-name:ILoutput; 	mso-style-parent:ILbase; 	mso-style-next:ILbase; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:0in; 	margin-left:.5in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:9.5pt; 	font-family:Tahoma; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.programs, li.programs, div.programs 	{mso-style-name:programs; 	mso-style-parent:"c\# base text"; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:0in; 	margin-left:.5in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:10.0pt; 	font-family:Tahoma; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} p.cbasetext, li.cbasetext, div.cbasetext 	{mso-style-name:"c\# base text"; 	mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:justify; 	text-justify:inter-ideograph; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:11.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} p.ILbullets, li.ILbullets, div.ILbullets 	{mso-style-name:ILbullets; 	mso-style-parent:ILbase; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:0in; 	margin-left:.3in; 	margin-bottom:.0001pt; 	text-align:justify; 	text-justify:inter-ideograph; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	text-autospace:none; 	font-size:10.0pt; 	font-family:"Bookman Old Style"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 24pt; font-family: &amp;quot;Monotype Corsiva&amp;quot;; color: black;"&gt;Threads, Events and Mutexes&lt;/span&gt;&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Threads operate on the premise that the computer is definitely more expeditious than a human at executing tasks, resulting in the computer idling away most of its processing time, waiting for the human operator. Threads are a means of overcoming this wastage of processing time. They perform multiple tasks on a computer in rapid succession, thereby, creating the illusion of these tasks being executed simultaneously. No application can ever be comprehensive without employing threads. Before we try to infer what a thread does in the programming context, let us rummage through a few examples given below.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Without being discursive, let us venture out on our odyssey of understanding the concept of a thread with the assistance of a very diminutive program.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Hi");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ThreadStart ts = new ThreadStart(yyy.abc);&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(ts);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before Start");&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before Start&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;This one is bound to leave you astonished because, we had earlier talked about starting out with a 'dimunitive' program. However, by no stretch of the imagination can the above program qualify as miniscule. Besides, the only work accomplished by this function is that it calls the static function abc, which in turn displays 'Hi'. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;In &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;, we create an object ts, which is an instance of the class&lt;span style=""&gt;  &lt;/span&gt;ThreadStart, which is derived from Delegate. Therefore, even though ThreadStart is a class, it also happens to be a delegate, whose constructor is given a static function called abc. Function abc is placed in the yyy class so that other classes can also use it. The program will work in a similar manner even if the static function is placed in class zzz.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Next, we create another object t, which is an instance of Thread. The constructor of this object is given a ThreadStart object ts. Indirectly, ts stands for the static function yyy.abc since it is a delegate. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;So far, tranquility prevails and nothing transpires. The function yyy.abc too does not get called. But, as soon as we call Start off the thread, the function abc gets catapulted into action. Thus, the function abc is called only when the Start function is called. This is really no big deal. Note that classes beginning with Thread belong to the System.Threading namespace.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Hi");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The above program is similar to the previous one and resembles the samples supplied by Microsoft. The function abc to be called, is non-static and hence, an object name is needed to reference it. The ThreadStart delegate object is directly passed as a parameter to the Thread constructor.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public void pqr()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i+ "...");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.pqr));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;0 1 2 3 0...1...2...3...&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The example embodies a very large amount of code. However, it does not create any fresh ripples in our pond of knowledge. We have merely created two Thread objects t and t1, and passed their constructors a different delegate or function name, i.e. abc and pqr, respectively. Thereafter, the Start function has been called in t and t1. Here, the function abc gets called, which displays four numbers. Thereafter, the function pqr gets called, which also displays four numbers, but with three dots. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;You may wonder with trepidation as to when you will bite into the real meat. Keep your impatience in abeyance for a little while !&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="programs"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="programs"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="programs"&gt;public class yyy&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;public void abc()&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;System.Console.Write(i + " ");&lt;/p&gt;  &lt;p class="programs"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;public void pqr()&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;System.Console.Write(i+ "...");&lt;/p&gt;  &lt;p class="programs"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;public class zzz&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="programs"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="programs"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.pqr));&lt;/p&gt;  &lt;p class="programs"&gt;t.Start();&lt;/p&gt;  &lt;p class="programs"&gt;t1.Start();&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;0 0...1 1...2 2...3 3...&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Now, we are at the threshold of excitement. By adding the function Sleep, which is a static function in the Thread class, the functions abc and pqr get called simultaneously, although not sequentially. This is how the concept of a thread is implemented, i.e. it empowers your computer to accomplish multiple jobs at the same time. This process is also termed as multi-tasking. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Take the case of Microsoft Word. When you attempt to save a file, irrespective of the size of the file, Word appears to consume the same amount of time in completing this task. To expect it to save a 10MB file within a very short time period is a thought fraught with absurdity and contrary to reason. Actually, what the Word program does is that it creates a thread and then solicits the thread to save the file. While the thread is saving that file, another thread waits for the user to type something. Hence, the user is emancipated to continue working with Word. Thus, in effect, two tasks are being executed concurrently without the user being cognizant of it ! The same mechanism is employed by Excel and other similar products. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Any application under Windows runs in its own thread. Thus, if two programs are launched, there will be two threads running. The operating system refrains from playing favorites and gives an equal amount of time to each thread to execute. If there are two threads co-existing, then, out of every minute of processing time available, each of them will be allotted 30 seconds to execute. If a third program is now executed, a new thread will be launched and each of the three threads will be allotted only 20 seconds of the processor time per minute to execute. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;If, instead of running a third program, what if the second program itself creates a thread ? As before, this will result in the creation of a third thread and each thread will be allotted 20 seconds of time. The resultant effect would be that that the first program will be allotted 20 seconds of time, whereas the second program will get 40 seconds per minute of the processor time. Thus, the larger number of threads that a program creates, more will be the processor time allotted to it. If you crave for more time and attention from your computer, desist from throwing a tantrum. Instead, generate greater number of threads. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The computer allots a specific amount of time to each thread and then puts it to sleep. Thereafter, it executes another thread. The time given to each thread to execute its code is designated as a Time Slice. This allocation of Time Slices occurs so swiftly that each thread suffers from the hallucination that it enjoys the undivided attention of the computer. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The static function Sleep in the Thread class facilitates this process. Sleep is like the sandman. It puts the thread to sleep for a certain number of milliseconds, as specified in its parameter. In this case, it is 1 millisecond. In the earlier example, in a single time slice, the Thread executed all the code and the function completed execution. In this case, the Sleep delays it long enough for the next thread to execute, and thus, the code in the functions get called one after the other.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread t2 = Thread.CurrentThread;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + "." + t2.Name + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Name="One";&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Name="Two";&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;0.One 0.Two 1.One 1.Two 2.One 2.Two 3.One 3.Two&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Here, we have provided mental catharsis by simplifying the program. What we actually have done is given the same function name abc to our delegate. We have also used the property Name of the Thread class to assign a distinct name to each thread, i.e. One and Two respectively. Under normal circumstances, the names assigned are pre-ordained by the system. Now, both the threads will call the same function abc. How do we determine as to which thread is calling the function abc? &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Thread class can have members, which are either static or instance. CurrentThread is a static read-only property that returns a thread object, which represents the thread that has currently called the function. Here, Thread t2 will either represent t or t1, and the property Name will display the name of the thread executing the function.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="programs"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="programs"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="programs"&gt;public class zzz : Thread&lt;/p&gt;  &lt;p class="programs"&gt;{&lt;/p&gt;  &lt;p class="programs"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Compiler Error&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;a.cs(2,14): error CS0509: 'zzz' : cannot inherit from sealed class 'System.Threading.Thread'&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Thread class is a sealed class, therefore we cannot derive from it. The designers of the Thread class at Microsoft have held very doctrinaire opinions, in that, they believe that they have envisaged all the possible features required in this class. Thus, they have not provided any facility to override or modify it. Therefore, we are constrained to use the Thread class exactly as provided, without introducing any code that will complement or add to or subtract from the code of the Thread class. For your information, the Thread class in turn is derived from the interface ISerializable.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Hi");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.IsAlive);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.IsAlive);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Abort();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.IsAlive);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;False&lt;/p&gt;  &lt;p class="ILoutput"&gt;True&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi&lt;/p&gt;  &lt;p class="ILoutput"&gt;False&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Thread class has a property called IsAlive that reveals the current state of the Thread. When we create an object that looks like Thread, the thread is in a dead state and hence, the IsAlive property has a value of False. Start breathes life into the thread and executes through the delegate abc. The thread now comes alive, but the code in the thread function gets executed only after the subsequent WriteLine function, which displays the value of IsAlive as True. When we stop or Abort the Thread, the thread dies and the value of the property IsAlive reverts back to False. Thus, IsAlive can hold only one of the two values, False for dead or True for alive.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Hi");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;while ( !t.IsAlive )&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("hi1");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;In today's world, we are working on extremely fast machines. When we execute t.Start(), the thread is brought to life in a fraction of a second. Hence, the while loop is not executed because the condition becomes false immediately. Had the machine been slower, the while loop may have got called a few times, as it would have taken some time before the thread could have been brought to life. Thus, the speed of execution may vary, depending upon the speed of the machine. Whenever the sample code creates a thread, it always contains this while loop.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3 ; i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write("Hi " + i + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Over");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Over&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi 0 Hi 1 Hi 2 Hi 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The executable, a.exe, runs in its own thread. So, before calling the function Start, we already have one thread running. On calling the function Start, two threads run concurrently, independent of each other. The second thread executes the function abc independent of the first thread. The first thread executes the last WriteLine function and then stops, whereas the second thread continues executing the function abc till there is no more code to call. If, on your machine, the first thread's time slice gets over before executing the WriteLine function, then some code of the function abc may get executed before Over gets displayed in the function Main. It is reiterated yet again that, in case of threads, there can be no guarantee as to when the time slice of a thread will get over. Even the operating system is not sagacious enough to offer any guarantees in this regard.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3 ; i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write("Hi " + i + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Join();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Over");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hi 0 Hi 1 Hi 2 Hi 3 Over&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The function Join is a blocking function. It makes the program linger at the function Join till the thread finishes execution. Any code after the Join, in this case the WriteLine function, will be executed only after the thread dies. A blocking function will wait until the purpose it is waiting for has reached fructification. Thus, if we want to wait for a thread to complete execution, we use a Join. Join behaves like a party host, who is always the last to leave.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( ; ; ) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = t.Join(10000);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Over " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Over False&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Join function accepts a number as a parameter, which represents the maximum duration in milliseconds that it should wait for the thread to complete execution. In our example, the function abc will never end. Thus, the thread t will go on forever. Therefore, the Join function waits for 10 seconds, gives up and finally returns a False.&lt;/p&gt;  &lt;p class="ILbase"&gt;Therefore, we are empowered to decide the duration for which we want to wait for the thread to complete execution. Let us not forget that our application has not yet terminated and is still hanging around in memory. At this stage, if you press Ctrl-Alt-Del, you will see a list of programs running. Now, select the End Task option for the program called 'a'. An alternative approach could be to add the Abort function t.Abort() after the WriteLine function.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( ; ; ) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Join();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Unhandled Exception: System.Threading.ThreadStateException: Thread has not been started.&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at System.Threading.Thread.Join()&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at zzz.Main()&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;If there is no thread running, the Join function will throw the&lt;span style=""&gt;  &lt;/span&gt;exception of ThreadStateException. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("abc");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(3);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Abort();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Over");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(100);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc&lt;/p&gt;  &lt;p class="ILoutput"&gt;Over&lt;/p&gt;  &lt;p class="ILoutput"&gt;Unhandled Exception: System.Threading.ThreadStateException: Thread is running or terminated. Cannot restart.&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark &amp;amp; stackMark)&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at System.Threading.Thread.Start()&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at zzz.Main()&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;At first, we start the thread t by calling the Start function. Thereafter, we make the main thread sleep for a little while. Then, we abort the thread and again sleep for a little while, in order to enable the thread to fulfill its last wishes and finally die. Now that the thread is dead, we try and infuse life into it by calling Start again. A thread, which has died cannot be resuscitated. Since we have had the audacity to attempt this, the results are nearly cataclysmic, resulting in the generation of an exception which has to be caught.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("abc");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(3);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Abort();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Over");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(100);&lt;/p&gt;  &lt;p class="ILprg"&gt;try&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;catch (ThreadStateException e)&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("In Exception");&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;} &lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc&lt;/p&gt;  &lt;p class="ILoutput"&gt;Over&lt;/p&gt;  &lt;p class="ILoutput"&gt;In Exception&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The exception thrown is ThreadStateException, which needs to be caught in our code. Otherwise, the runtime message box is&lt;span style=""&gt;  &lt;/span&gt;displayed to the user.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Thread class constructor can throw two types of exceptions:- &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;ArgumentNullException -&lt;span style=""&gt;  &lt;/span&gt;When it is called without a delegate in the constructor. &lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;SecurityException - When the program does not have permission to create a thread.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("abc");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.ApartmentState);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.ApartmentState = ApartmentState.STA;&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.ApartmentState);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Unknown&lt;/p&gt;  &lt;p class="ILoutput"&gt;STA&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We all have our own apartments, which are normally done up as per our preferences i.e. 'We are the kings of our castles'. Threads also have apartments. Any thread can be asked to execute either in a single-threaded apartment or in a multi-threaded apartment. These values can be established using the property ApartmentState, either once at the beginning, or while the thread is running. The various values that ApartmentState can assume are as follows:&lt;/p&gt;  &lt;p class="ILbullets"&gt;· STA&lt;span style=""&gt;                    &lt;/span&gt;: Single Threaded Apartment.&lt;/p&gt;  &lt;p class="ILbullets"&gt;· MTA&lt;span style=""&gt;                    &lt;/span&gt;: Multi Threaded Apartment. &lt;/p&gt;  &lt;p class="ILbullets"&gt;· Unknown&lt;span style=""&gt;           &lt;/span&gt;: Default value assigned when no value is&lt;span style=""&gt;                            &lt;/span&gt;set. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We, however, cannot use numbers for a string. Thus, an enum called ApartmentState has been used. It holds three values i.e. 0, 1 and 2 corresponding to STA, MTA and Unknown respectively. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("abc " + Thread.CurrentThread.IsBackground);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt; " + Thread.CurrentThread.IsBackground);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt; False&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc False&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;A thread executes either in the background or in the foreground. The property IsBackground indicates the mode in which the thread will run. An important point to be noted here is that, a thread which executes in the background automatically shuts down when its main program quits.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0 ; i&lt;=100; i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("abc " + i);&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt; " + Thread.CurrentThread.IsBackground);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.IsBackground = true;&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(10);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output &lt;/u&gt;(t.IsBackground = true)&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt; False&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc 0 &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output &lt;/u&gt;(t.IsBackground = false)&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt; False&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc 0&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc 1&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc 2&lt;/p&gt;  &lt;p class="ILoutput"&gt;..&lt;/p&gt;  &lt;p class="ILoutput"&gt;..&lt;/p&gt;  &lt;p class="ILoutput"&gt;abc 100&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;When you change the true to false in t.IsBackground, the output shows the code of function abc being executed. The for loop displays values from 0 to 100.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;By changing the property IsBackground of a thread to true, the thread terminates when the main program stops. Thus, the for loop does not have the time to display values upto 100. At times, the program displays abc with a value of 0.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The sleeps are used to demonstrate the effect of the first thread shutting down and the second carrying on execution. On changing the property IsBackground to false, the thread takes its own sweet time to execute its code without any regard for the first thread, which may or may not have completed its job. So, the foreground threads behave exactly in the same manner as the background threads, when the property is initialized to true.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=10;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public void pqr()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=10;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i+ "...");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.pqr));&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(t.Priority);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Priority = ThreadPriority.Highest;&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Priority = ThreadPriority.Lowest;&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Normal&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;0 1 2 3 4 0...5 1...6 2...7 3...8 4...9 5...10 6...7...8...9...10...&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We are at liberty to decide the duration of the time-slice to be allotted to our thread vis-a-vis other threads. This can be achieved by setting the Priority property accordingly. By default, the priority level is 2. Hence, we see&lt;span style=""&gt;  &lt;/span&gt;'Normal' displayed as the output. All threads start at this priority level. The ThreadPriority enum comprises of five levels of priority, which are as follows:&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;0 - Zero&lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;1 - BelowNormal&lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;2 - &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Normal&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;3 - AboveNormal&lt;/p&gt;  &lt;p class="ILbullets"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;•&lt;span style=""&gt;     &lt;/span&gt;&lt;/span&gt;4 - Highest&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;In our program, we have changed the priority of thread t to the highest possible and that of thread t1 to the lowest. As a result, Thread t is accorded more time than thread t1, and it finishes its for loop much before thread t1 can do so.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;try&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc");&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( ; ; ) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;catch ( System.Exception e)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc Exception " +e.ToString() );&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;finally&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc Finally");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(10);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Abort();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;in abc&lt;/p&gt;  &lt;p class="ILoutput"&gt;in abc Exception System.Threading.ThreadAbortException: Thread was being aborted.&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at yyy.abc()&lt;/p&gt;  &lt;p class="ILoutput"&gt;in abc Finally &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Aborting a Thread while it is busy executing some code generates an exception. Thus, the function abc will be sent an exception, resulting in a call to the 'catch' and 'finally' clauses. The thread will be terminated after executing the code in the Catch and the Finally clause. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;try&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc");&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( ; ; ) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;catch ( System.Exception e)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc Exception " +e.ToString() );&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;finally&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("in abc Finally");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Abort();&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;(no output)&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Aborting a thread before it has started execution does not generate&lt;span style=""&gt;  &lt;/span&gt;any exceptions, since the thread is in a dead state. Hence, no code in abc ever gets called. This situation is akin to the one where you don your best attire to watch cricket live at the stadium, but the show gets ruined due to heavy downpour, resulting in the match being abandoned without a ball being bowled ! &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for (int i = 1 ; i&lt;= 10 ; i++ ) &lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + " " );&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(10);&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Suspend();&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("\n After Suspend");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(10);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before Resume");&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Resume();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt; &lt;/span&gt;After Suspend&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before Resume&lt;/p&gt;  &lt;p class="ILoutput"&gt;2 3 4 5 6 7 8 9 10&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We are allowed to Suspend a thread executing its code, at any point in time. In the above program, we let the thread run for a little while and then Suspend it. Thereafter, we Resume it. Thus, the thread is like a puppet in our hands. We can decide when and which strings to pull and the thread does our biding. If the thread has already been suspended, then Suspending it once again has no effect, and thus, it does not result in an error. A single Resume is enough to undo a million Suspends.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 0; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread t2 = Thread.CurrentThread;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + " " + t2.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;0 2 0 3 1 2 1 3 2 2 2 3 3 2 3 3 &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Every thread is assigned a number internally. This number is called the HashCode. Hashing is the process of assigning a number to an entity so that it can easily be located from a long list. This hash number is useful and is pressed into service when we are required to keep track of a large number of threads internally.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=5;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1000);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 2 2 3 2 4 2 5 2 1 3 2 3 3 3 4 3 5 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Let us now clarify the abstract concept of the life of a thread with the help of an example. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Any resource that many people desire is called a shared resource. Imagine the chaos that would be caused if five programs tried to simultaneously use a single network printer for printing, during their respectively time-slices. This would result in the printer printing a few pages for program 1, then a few pages for program 2, and so on. The printer will keep printing merrily, but the printed output will all be jumbled up.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Thus, ideally, one program should use a shared resource at a time, till its job is complete. For this, a method has to be implemented by means of which, unless one program finishes executing some specific code in a function, no other program should be allowed to execute it. Thus, all other programs would have to wait until the first thread finishes execution. &lt;/p&gt;  &lt;p class="ILbase"&gt;Let us assume that function abc contains code which sends a request to the printer to print. The thread t gets the first shot at running abc. The second thread t1 has to wait until thread t finishes execution, even if the duration of executing abc takes more time than one time slice, due to a large value being assigned as a parameter to the sleep function. This is achieved by using the static function Enter of the class Monitor.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The function Enter is given an object which refers to the class in which the function resides.&lt;span style=""&gt;  &lt;/span&gt;From that point onwards, every thread has to wait at Enter. The barrier lowers only when Exit is called from the Monitor class. Enter acts as a fussy security guard who decides as to which thread is to be prohibited and which one is to be permitted to execute code. No two threads can ever enter the Enter function together. It is a rigid one way lane from Enter to Exit. One car is allowed in at one time and another car can pass through only after the first car leaves Exit. You can see that the names Enter and Exit have been chosen very aptly. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class ggg&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;};&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public ggg g1;&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc( )&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i &lt;= 3; i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Console.Write(" Hell " + i);&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Wait(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;Console.Write(" Waitabc " + i);&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Pulse(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;};&lt;/p&gt;  &lt;p class="ILprg"&gt;public class xxx&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public ggg g1;&lt;/p&gt;  &lt;p class="ILprg"&gt;public void pqr( )&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i &lt;= 3; i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Console.WriteLine(" Everyone " + i);&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Pulse(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Wait(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;Console.Write(" Waitpqr " + i);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(g1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;};&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void&lt;span style=""&gt;  &lt;/span&gt;&lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;(String[] args)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ggg&lt;span style=""&gt;  &lt;/span&gt;g = new ggg( );&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy( );&lt;/p&gt;  &lt;p class="ILprg"&gt;a.g1 = g;&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start( );&lt;/p&gt;  &lt;p class="ILprg"&gt;xxx b = new xxx();&lt;/p&gt;  &lt;p class="ILprg"&gt;b.g1 = g;&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(b.pqr));&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start( );&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;};&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Hell 1 Everyone 1&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt; &lt;/span&gt;Waitabc 1 Hell 2 Waitpqr 1 Everyone 2&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt; &lt;/span&gt;Waitabc 2 Hell 3 Waitpqr 2 Everyone 3&lt;/p&gt;  &lt;p class="ILoutput"&gt;cs Waitabc 3 Waitpqr 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The above example may be a protracted one, yet it is fascinating.&lt;/p&gt;  &lt;p class="ILbase"&gt;The world has never been able to work with each other. The only global body we have is the UNO. People are mostly loners. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;In the entry point function &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;, we create an object g, which is an instance of a class ggg, having no code or variable. It embodies the emptiness of space. This is a class that is incapable of doing any good or bad. We then create two objects that look like yyy and xxx respectively, and pass them as delegates, so that the threads can call functions abc and pqr. We also initialize the object g1, an instance of ggg, in each of them to g. This is crucial. The g1's in yyy and xxx represent the same g that is created in &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;After initializing the requisite members, we activate the two threads. As earlier, let us assume that the function abc gets called first. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Monitor.Enter considers taking a handle to any object, which is to be synchronized between multiple instances of threads, as its first parameter. This function needs an Exit function to release its handle. Thus, the number of Exits in the program must correspond to the number of Enters.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;It prints "Hell", and then due to the Wait function, it waits indefinitely, till it finally receives runtime notification. However, the thread accomplishes nothing significant. Thus, we do not see the Waitabc displayed, since it is entered after the Wait function.&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILbase"&gt;The second thread starts executing the function pqr. Monitor.Enter uses the same synchronized object, and now it displays Everyone. The next function to be called in pqr is Monitor.Pulse. Pulse does a very simple thing. It wakes up any thread having the same handle, which happens to be waiting at a Wait. Thus, the thread in abc wakes up. However, the one in pqr waits for someone to Pulse it.&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;By using Wait and Pulse, we can easily play a game of tag. The thread t performs some work and waits for thread t1 to wrap up whatever work it is preoccupied with. Thread t does not know how long thread t1 will take to fulfill its side of the bargain. But no sweat! Thread t waits at a Wait for the thread t1 to Pulse it. Then, thread t1 waits at a Wait for thread t to do some work. When thread t concludes, it Pulses thread t1, and so on. This can go on and may involve some other threads too. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The threads use the handle g, which is the synchronized region. It is akin to being an integral part of a clandestine social group. The parameter to these Monitor functions clubs them together as a group. If you change the handle, the group breaks up, leaving your thread in a lurch. The Wait function can also be made to wait for a specified time period.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;If we change the line Monitor.Wait(g1) to Monitor.Wait(g1,0), the output changes dramatically. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;A monitor is associated with an object on demand and it cannot be instantiated at all. If the constructor is private, we can never create an object. But, the static functions of that object can be used. The Monitor functions can be called from anywhere since they are unbound. There are no restrictions on the sources of the object to be called. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy &lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;() {&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 2&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Exit function can be called as often as one desires. In this program, we have two threads, t and t1. Let us assume that thread t has the first go. At this time, it will pass through the first Monitor.Enter, as well as the second Monitor.Enter, without waiting at all. However, thread t1 will have to wait at the first Monitor.Enter, since the thread t called the Enter function twice, but Exited only once. Thus, the program never quits out. Had it called Exit twice, the thread t1 too would have woken up. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy {&lt;/p&gt;  &lt;p class="ILprg"&gt;public int j=1;&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(j);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(j);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;() {&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 2&lt;/p&gt;  &lt;p class="ILoutput"&gt;Unhandled Exception: System.Threading.SynchronizationLockException: Exception of type System.Threading.SynchronizationLockException was thrown.&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;span style=""&gt;   &lt;/span&gt;at yyy.abc()&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Monitor.Enter takes an object, and not a variable, as a parameter. This is the reason why we used this parameter or some reference object, in the earlier programs. If a variable or a value object is used, an exception will be thrown. Thus, value types or null objects are not allowed as parameters to Monitor.Enter.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class xxx&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class ttt&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;static int p = 1;&lt;/p&gt;  &lt;p class="ILprg"&gt;xxx x&lt;span style=""&gt;  &lt;/span&gt;= new xxx();&lt;/p&gt;  &lt;p class="ILprg"&gt;ttt t&lt;span style=""&gt;  &lt;/span&gt;= new ttt();&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;if ( p == 1)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(x);&lt;/p&gt;  &lt;p class="ILprg"&gt;p++;&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;else&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Enter(t);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1000);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(x);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;1 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Enter function must be used with some caution. The variable p initially has a value of 1. The first thread t sees the value of p as 1. Hence, the 'if' statement is true. Thus, it crosses Monitor.Enter with x as a parameter. It then takes a snooze at the Sleep function, while the second thread t1 executes function abc, where it sees the value of variable p as 2. This thread now meets the Monitor.Enter function, with t as the parameter. The object reference given to this Enter is entirely at variance with the object given to the earlier one. Thus, both the threads execute the Enter function, which fails the very objective of the Enter function. For Enter to work as expected, it should be provided with the same object as a parameter to itself. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The concept of a Lock is normally used to explain the Monitor class. One thread gets a Lock, while the others wait until the lock is released.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = Monitor.TryEnter(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(b);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1000);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main() {&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;True&lt;/p&gt;  &lt;p class="ILoutput"&gt;False&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;1 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The TryEnter function is similar to the Enter function, but it does not block. If the thread enters successfully, TryEnter returns a true. This is what happens the first time. But in the case of the second thread t, it returns a false, even when it enters the critical section.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs &lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = Monitor.TryEnter(this,1000);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(b);&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1000);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine(i + " " + Thread.CurrentThread.GetHashCode() + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;Monitor.Exit(this);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;True&lt;/p&gt;  &lt;p class="ILoutput"&gt;False&lt;/p&gt;  &lt;p class="ILoutput"&gt;1 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;1 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;2 3 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 2 &lt;/p&gt;  &lt;p class="ILoutput"&gt;3 3&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The TryEnter function is overloaded to accept a number as a parameter, which represents the time duration for which the TryEnter function should block or wait. In our case, the timeout exceeds the time that thread t spends in the function. Hence, we get a value of False. If we add an extra zero to the time parameter, it will return a true instead. If the value of the parameter is infinite, the behaviour of the TryEnter becomes akin to that of Enter.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;u&gt;&lt;span style=""&gt;Thread Attributes&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class yyy&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;[System.ThreadStaticAttribute ()]&lt;/p&gt;  &lt;p class="ILprg"&gt;public static int j = 1;&lt;/p&gt;  &lt;p class="ILprg"&gt;public static int k = 1;&lt;/p&gt;  &lt;p class="ILprg"&gt;public void abc()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;for ( int i = 1; i&lt;=3;i++)&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread t2 = Thread.CurrentThread;&lt;/p&gt;  &lt;p class="ILprg"&gt;j++;k++;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.Write(i + "." + t2.Name + " j=" + j + " k=" + k + " ");&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread.Sleep(1);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main() {&lt;/p&gt;  &lt;p class="ILprg"&gt;yyy a = new yyy();&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;Thread&lt;span style=""&gt;  &lt;/span&gt;t1 = new Thread(new ThreadStart(a.abc));&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Name="One";&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Name="Two";&lt;/p&gt;  &lt;p class="ILprg"&gt;t.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;t1.Start();&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;1.One j=1 k=2 1.Two j=1 k=3 2.One j=2 k=4 2.Two j=2 k=5 3.One j=3 k=6 3.Two j=3 k=7&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;A static variable is a loner, as reiterated by us on numerous occasions. It belongs to the class and not to an object. Thus, there will always be a single static variable. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Let us consider a case where we have two threads t and t1 executing code in the same function abc, that also contains static variables j and k. The first question that strikes us is 'Will each of the threads see the same static variable or a different one?' Also, if we assume that both threads cater to the same static variable, when one thread increments the variable, will the other thread see the new value? And if not, then, is the compiler creating a separate static variable for each thread?&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Too many questions that need answers! &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We want to possess the best of both the worlds. At times, we need the threads to work on the same static variable, while at other times, we need the threads to access separate copies of the static variable. The default behaviour is that of the static variable being shared. Thus, the variable k is incremented by both the threads, and each thread sees the same value. The value of k finally reaches 7 at the end. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The variable j has an attribute ThreadStaticAttribute above it. This attribute may have a fancy name, but it merely creates a separate variable for each thread executing the function. Thus, we have two static variables j, one for each thread t and t1. Any changes made to the value of the variable j by t, does not get reflected in the static variable j of the thread t1.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;1.One j=2 k=2 1.Two j=3 k=3 2.Two j=4 k=4 2.One j=5 k=5 3.Two j=6 k=6 3.One j=7 k=7&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The above attribute only acts on static variables. We see the above output when we remove static from the variables j and k. The compiler is very clear. The attribute ThreadStaticAttribute is only to be used on static variables, but when applied on non-static variables, the compiler does not generate any error or warning. It simply ignores the attribute. Thus, instance variables are shared across threads, whereas, local variables like i are independent of threads. Thus, a variable can either be shared across threads or may be independent of the thread. No in-between options are allowed.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;u&gt;&lt;span style=""&gt;Events&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main() {&lt;/p&gt;  &lt;p class="ILprg"&gt;ManualResetEvent a;&lt;/p&gt;  &lt;p class="ILprg"&gt;a = new ManualResetEvent(false) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before WaitOne " );&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = a.WaitOne(1000,false);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before WaitOne &lt;/p&gt;  &lt;p class="ILoutput"&gt;After WaitOne False&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;We have created an object a that is an instance of a ManualResetEvent class. The constructor is assigned a value of false. Then, we call a function WaitOne from this class with a number as the first parameter, and a boolean value as the second parameter. This number, 1000, is the number of milliseconds for which we want the thread to wait at the function WaitOne. The thread therefore waits for one second before quitting out, and then returns a False. Had we used the enum Timeout.Infinite that has a value of -1, we could have made the function wait forever. Thus, we can keep a thread waiting either for a specified duration of time or forever.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ManualResetEvent a;&lt;/p&gt;  &lt;p class="ILprg"&gt;a = new ManualResetEvent(true) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before WaitOne " );&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = a.WaitOne(1000,false);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before WaitOne &lt;/p&gt;  &lt;p class="ILoutput"&gt;After WaitOne True&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;By changing the value in the constructor to true, the thread just refuses to wait for anyone. It just whizzes past, without even acknowledging the presence of the function WaitOne. Further, the return value of WaitOne i.e. b returns a True. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Let us delve a little deeper into this mystery. A ManualResetEvent is like a boolean variable. It can possess only one of the two values, true or false. When we first created such an object, we gave it a value of false. So, the function WaitOne waited till the Event object turned into True or the time value expired. Since the time duration got over while waiting, and the value of the Event object was not set to True, it stopped blocking and returned with a value of false. &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;In the next example, the event object already has a value true and hence, there is no wait. Here, the function WaitOne returns true because the non-blocking in this case, cannot be attributed to a timeout. Thus, a ManualResetEvent has two states, true or false; or in technical lingo, signaled or non-signaled. A value of true implies a signaled state, while a false would mean that it is in the non-signaled state.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ManualResetEvent a;&lt;/p&gt;  &lt;p class="ILprg"&gt;a = new ManualResetEvent(true) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before WaitOne " );&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = a.WaitOne(1000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;b = a.WaitOne(10000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After second WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILbase"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before WaitOne &lt;/p&gt;  &lt;p class="ILoutput"&gt;After WaitOne True&lt;/p&gt;  &lt;p class="ILoutput"&gt;After second WaitOne True&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Since we do not consider ourselves to be very cerebral, we shall desist from using fancy terminology like signaled or non-signaled. Instead, we shall stick to the simple true and false. We initially created the object a to be true or signaled (Oops! There we go again!). It then passed the first and the second WaitOne without waiting. This occurred because it is a Manual ResetEvent (as the name itself suggests), and not automatic. Once it is set to true, the event cannot change to false automatically. This has to be accomplished manually.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ManualResetEvent a;&lt;/p&gt;  &lt;p class="ILprg"&gt;a = new ManualResetEvent(true) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before WaitOne " );&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = a.WaitOne(1000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;a.Reset();&lt;/p&gt;  &lt;p class="ILprg"&gt;b = a.WaitOne(10000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After second WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before WaitOne &lt;/p&gt;  &lt;p class="ILoutput"&gt;After WaitOne True&lt;/p&gt;  &lt;p class="ILoutput"&gt;After second WaitOne False&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The Reset function can be used to change the state from true to false as it changes the state to false. Hence, it has to wait in queue like a commoner, since the event ignores the earlier WaitOne. After some time, it gets activated due to a timeout and the function WaitOne returns a False.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;u&gt;a.cs&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILprg"&gt;using System.Threading;&lt;/p&gt;  &lt;p class="ILprg"&gt;public class zzz&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;public static void Main()&lt;/p&gt;  &lt;p class="ILprg"&gt;{&lt;/p&gt;  &lt;p class="ILprg"&gt;ManualResetEvent a;&lt;/p&gt;  &lt;p class="ILprg"&gt;a = new ManualResetEvent(false) ;&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("Before WaitOne " );&lt;/p&gt;  &lt;p class="ILprg"&gt;a.Set();&lt;/p&gt;  &lt;p class="ILprg"&gt;bool b = a.WaitOne(1000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;b = a.WaitOne(10000,true);&lt;/p&gt;  &lt;p class="ILprg"&gt;System.Console.WriteLine("After second WaitOne " + b);&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;}&lt;/p&gt;  &lt;p class="ILprg"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/p&gt;  &lt;p class="ILoutput"&gt;Before WaitOne &lt;/p&gt;  &lt;p class="ILoutput"&gt;After WaitOne True&lt;/p&gt;  &lt;p class="ILoutput"&gt;After second WaitOne True&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Now, despite the fact that that the Event is originally false or non-signaled, the Set function sets it to true or the signaled state. At this stage, no power on earth is equipped to stop the event as it surges past the WaitOnes, treating them with disdain. It is not in the least concerned about stopping-by to pay homage to them. Such arrogance !&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;The class ManualResetEvent is a sealed class, like most other classes belonging to the Thread family. The developers at Microsoft were of the belief that no one would be able to add any more value to the class, and thus forbade any changes. This class is also derived from another class called WaitHandle, which in fact, embodies functions like WaitOne etc. The constructor has to be passed a parameter that affirms the initial state of the Event object. No default state is available. The Set and Reset methods return a boolean value, which indicates whether the change has taken place successfully or otherwise.&lt;/p&gt;  &lt;p class="ILbase"&gt; &lt;/p&gt;  &lt;p class="ILbase"&gt;Wait
