<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Living .NET...  : .NET 2.0</title><link>http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx</link><description>Tags: .NET 2.0</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Implementing Timeout &amp; Retry</title><link>http://msmvps.com/blogs/manoj/archive/2006/11/01/Implementing-Timeout-_2600_-Retry.aspx</link><pubDate>Wed, 01 Nov 2006 11:58:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:235323</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=235323</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2006/11/01/Implementing-Timeout-_2600_-Retry.aspx#comments</comments><description>I have come across several situations where I need some sort of Timeout functionality for a particular operation. At the same time, I also needed a provision for retrying the operation a few times before calling quits. I thought about a solution using...(&lt;a href="http://msmvps.com/blogs/manoj/archive/2006/11/01/Implementing-Timeout-_2600_-Retry.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://msmvps.com/aggbug.aspx?PostID=235323" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Predicates in Action</title><link>http://msmvps.com/blogs/manoj/archive/2006/08/29/Predicates-in-Action.aspx</link><pubDate>Tue, 29 Aug 2006 07:12:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:110761</guid><dc:creator>Manoj G</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=110761</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2006/08/29/Predicates-in-Action.aspx#comments</comments><description>Get to know about one of the cool new things in .NET 2.0 - Predicates!...(&lt;a href="http://msmvps.com/blogs/manoj/archive/2006/08/29/Predicates-in-Action.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://msmvps.com/aggbug.aspx?PostID=110761" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Tip: Debugging Windows Services</title><link>http://msmvps.com/blogs/manoj/archive/2006/04/04/89042.aspx</link><pubDate>Mon, 03 Apr 2006 18:25:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:89042</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=89042</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2006/04/04/89042.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;The other day, I was watching the PDC presentations on WCF and one of them was on hosting WCF services by Steve Maine. Part of the presentation was about hosting Indigo on Windows services (or NT Services). One of the demos had a small and very interesting tip on debugging service startup, which I shall try to elaborate here. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;I always wondered how the service startup code could be debugged. There are two problems which you would face invariably. First of all, there is no process to which you can attach a debugger to start with. I have done stupid things in the past to step into startup code - by adding a Thread.Sleep in the OnStart method, assuming that this would give me enough time to attach the debugger to the newly started process. This isn’t very smart as you would hit the second problem – the Service Controller Manager (SCM) would time the service out way too soon. Not to worry much - there is any elegant solution to both these problems. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;You need not add a Thread.Sleep anymore – just add a Debugger.Break in your code. This isn’t new, but I simply hadn’t found a use for this before. This method is actually pretty useful if you want to conditionally attach the debugger in situations like this. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;The solution to the problem of the SCM timing out is a method in the ServiceBase class (System.ServiceProcess) that has been added in .NET 2.0. This method is the &lt;STRONG&gt;RequestAdditionalTime&lt;/STRONG&gt;, which takes a single parameter – the amount of time in milliseconds that the SCM has to wait additionally before pulling the plug on the service. Note that this method can only be called inside of OnStart, OnPause, OnContinue and OnStop (basically all the commands you can forward to the SCM). &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Neat!&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=89042" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Useful additions in .NET 2.0 -  Part 3: EventHandler&lt;TEventArgs&gt;</title><link>http://msmvps.com/blogs/manoj/archive/2006/01/02/80141.aspx</link><pubDate>Sun, 01 Jan 2006 19:28:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:80141</guid><dc:creator>Manoj G</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=80141</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2006/01/02/80141.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;If your .NET class needs to generate events, at a minimum, you typically do the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;1)&amp;nbsp;Create a new class which derived from EventArgs – the instance of this class would be used to communicate certain information to the event handler about the event itself. For example, CacheExpiryEventArgs.&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;2)&amp;nbsp;A new delegate type whose instance points to a method, the signature of which looks something like: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public delegate void CacheExpiryEventHandler(object sender, CacheExpiryEventArgs e);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;3)&amp;nbsp;You declare an event which is associated with the delegate you created in (2). For example,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public event CacheExpiryEventHandler CacheExpired&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Now, for every event in your application, you invariably create as many delegate types. If you notice, each of those delegates differs only by the second argument of the event handler – the class representing the event arguments. Now, wouldn’t it be great if you had a generic delegate parameterized by the respective EventArgs argument. With generics in .NET 2.0, this is exactly what you get, in the form of &lt;STRONG&gt;EventHandler&amp;lt;TEventArgs&amp;gt;.&lt;/STRONG&gt; With this in place, our example now would look like:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public event EventHandler&amp;lt;CacheExpiryEventArgs&amp;gt; CacheExpired;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;This is definitely convenient, as it would reduce the number of delegates that are created in any application. Generics is a great addition in .NET 2.0, which not only gives you performance and strong-typing, but also certain productivity benefits like in this case, and for that matter Nullable&amp;lt;T&amp;gt;, List&amp;lt;T&amp;gt; and may such instances.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=80141" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Useful additions to .NET 2.0 - Part 2: Nullable Types</title><link>http://msmvps.com/blogs/manoj/archive/2005/11/20/76046.aspx</link><pubDate>Sun, 20 Nov 2005 07:14:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:76046</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=76046</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/11/20/76046.aspx#comments</comments><description>&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Nullable types,&amp;nbsp;put in simple terms can be thought of as a way of having nullable value types. Quite obviously, one of the largest applicability of this concept is that of database programming, where you can associate a null value with any datatype. Not too long ago, while coding the data access layer, I did quite a lot of magic value checks on values to see whether I had to associate a null value (DBNull.Value) to the corresponding database parameter. This included Guid.Empty, Int32.MinValue, DateTime.MinValue and so on. So, I had to create one helper method for all the types that needed such checks. The example for int is shown below:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;static&amp;nbsp;object&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;GetDbIntValue(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;val)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;(val&amp;nbsp;==&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;.MinValue)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;DBNull.Value&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&amp;nbsp;&lt;FONT color=#400000&gt;val&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;}&lt;BR&gt;&lt;/DIV&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Now, this effort is not good in a lot of ways though it serves its purpose. This methodology would require a handshake between the Business Logic Layer (BLL) and the Data Access Layer (DAL) as to what values are acceptable and what are not. The problem is that there is no universally accepted&amp;nbsp;set for the same, and hence there would be semantic coupling&amp;nbsp;between the Biz and the DAL layers.&amp;nbsp;The handsome alternative to this situation would be to use Nullable types. Wherever you used magic values, replace them with the corresponding instances of Nullable&amp;lt;T&amp;gt;. Most typically, these would be in the data transfer objects (DTO). In the DAL,&amp;nbsp;we could now have a single helper function (in lieu of many in the earlier case), which looks something&amp;nbsp;like:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;static&amp;nbsp;object&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;GetDbValue&amp;lt;T&amp;gt;(Nullable&amp;lt;T&amp;gt;&amp;nbsp;val)&amp;nbsp;where&amp;nbsp;T&amp;nbsp;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;struct&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;if&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;(val.HasValue)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;val.Value;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;else&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;return&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;DBNull.Value;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;}&lt;BR&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;An adroit&amp;nbsp;developer might question&amp;nbsp;whether this helper nethod is really required. Why not have the IDbDataParameter instances 'infer' the right Dbtype from correponding nullable types. For example, you might have wanted this snippet to work without a hitch:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;Guid?&amp;nbsp;id&amp;nbsp;=&amp;nbsp;Guid.NewGuid();&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New"&gt;//Just&amp;nbsp;an&amp;nbsp;example&amp;nbsp;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;SqlCommand&amp;nbsp;cmd&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;SqlCommand("Select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;Sample&amp;nbsp;where&amp;nbsp;id&amp;nbsp;=&amp;nbsp;@Id");&lt;BR&gt;cmd.Parameters.AddWithValue("@Id",&amp;nbsp;id);&lt;BR&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080&gt;But unfortunately, at this point of time, there is no conversions built in for nullable types and you would end up getting this exception message:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial color=#ff0000 size=2&gt;No mapping exists from object type System.Nullable`1[[System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] to a known managed provider native type.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;So, till there is support for Nullable types from System.Data (not sure why it should not be), you are better off using the simple helper listed earlier. &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Before closing off, I would recommend that you read &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/vcsharp/2005/overview/language/nullabletypes/"&gt;&lt;FONT color=#0000ff&gt;this article&lt;/FONT&gt;&lt;/A&gt;&lt;/STRONG&gt; to understand&amp;nbsp;all aspects of Nullable types.&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#000080&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;Nullable types, unfortunately, is fully supported only in C# 2.0, and not in VB. In other words, VB does not have the additional language additions and compiler changes needed to support nullable types in a way C# does. However, nothing stops you from using Nullable&amp;lt;T&amp;gt; in VB; it is just that you would not have the shortcut notations like in C# (int? etc). You are encouraged to read &lt;STRONG&gt;&lt;A href="http://www.panopticoncentral.net/archive/2004/06/04/1180.aspx"&gt;&lt;FONT color=#0000ff&gt;this blog post&lt;/FONT&gt;&lt;/A&gt;&lt;/STRONG&gt; by Paul Vick, who explains this in detail.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=76046" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>BackgroundWorker and SynchronizationContext</title><link>http://msmvps.com/blogs/manoj/archive/2005/11/03/74120.aspx</link><pubDate>Thu, 03 Nov 2005 04:40:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:74120</guid><dc:creator>Manoj G</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=74120</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/11/03/74120.aspx#comments</comments><description>&lt;P style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;FONT color=#000080&gt;I have mentioned umpteen number of times earlier - .NET 2.0 comes with a wealth of new classes that have been added to the BCL. Today’s turn is of &lt;STRONG&gt;BackgroundWorker&lt;/STRONG&gt;. If you look at the available documentation (circa Beta 2), this is what you will find: &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;FONT color=#000080&gt;&lt;EM&gt;“Executes an operation on a separate thread”. You first reaction would be “Heck, what’s so “new” about that?”&lt;/EM&gt; Okay, so let’s spelunk into its properties and methods and try to find out. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9.5pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-size: 13.5pt"&gt;&lt;o:p&gt;&lt;FONT color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0&gt;

&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 6.15in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" colSpan=2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Methods&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;RunWorkerAsync&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Starts the designated method on a separate threadpool thread.&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;CancelAsync&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Requests the cancellation of the pending background operation&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 3"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 6.15in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" colSpan=2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Events&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 4"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;ProgressedChanged&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;This is called when the ReportProgress method is called&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 5"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;RunWorkerCompleted&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Occurs when the background operation is completed&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 6; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;DoWork&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Occurs when the RunAsync method is called.&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Again, after looking at these, you thoughts wouldn’t change – “&lt;I style="mso-bidi-font-style: normal"&gt;Still, what’s so great about the same? I had created similar helpers in .NET 1.1&lt;/I&gt;.”. &lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Fine, let me tell what’s new. The very interesting aspect about the BackgroundWorker is the fact that RunWorkerCompleted and ProgressChanged event handlers would execute on the thread that created the BackgroundWorker object – most typically on a Windows form main thread (the thread on which the UI controls are created). Therefore, you now do not fall into a trap that you used to fall into earlier – updating a winform control on the wrong thread and facing unpredictable results. (Note that the DoWork method runs on a separate threadpool thread – do not update UI controls on that method) &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;So, you would now say: “&lt;I style="mso-bidi-font-style: normal"&gt;Cool, the BackgroundWorker probably has a reference to the &lt;STRONG&gt;ISynchronizeInvoke&lt;/STRONG&gt; object, and it would call &lt;STRONG&gt;Invoke &lt;/STRONG&gt;on it to dispatch the method on the right thread.&lt;/I&gt; &lt;I style="mso-bidi-font-style: normal"&gt;(System.Windows.Forms.Contrtol class implements the&lt;/I&gt; &lt;I style="mso-bidi-font-style: normal"&gt;ISynchronizeInvoke interface) &lt;/I&gt;”.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;If you look closely, the BackgroundWorker is actually agnostic of the environment it runs in. It could not even be a winform application, or even if it was, it does not really rely on ISynchronizeInvoke directly. So, how does this magic happen?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;With the help of the valuable services of Reflector, I came to know about a new class (a set of them actually) introduced in .NET 2.0, which &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;are responsible for this magic – &lt;STRONG&gt;SynchronizationContext&lt;/STRONG&gt;. Here’s what the documentation says:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9.5pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-size: 13.5pt"&gt;&lt;o:p&gt;&lt;FONT color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9.5pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-size: 13.5pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;FONT color=#000080&gt;“&lt;I style="mso-bidi-font-style: normal"&gt;Provides the basic functionality for propagating a synchronization context in various synchronization models. &lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;The purpose of the synchronization model implemented by this class is to allow the internal asynchronous/synchronization operations of the common language runtime (CLR) to behave properly with different synchronization models. This model also simplifies some of the requirements that managed applications have had to follow in order to work correctly under different synchronization environments&lt;/I&gt;”&lt;SPAN style="FONT-SIZE: 8pt; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Can’t gather much from this explanation isn’t it? What is does mean perhaps is no more Control.Invoke. But it appears as if it is analogous to the thread’s Context object we had earlier, and a bit more specialized.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;By now, it would have rung another bell with you. As of .NET 2.0, in the case of Thread.Start method, the security context of the creating thread would be passed to the newly created thread. Guess what is behind this?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;I tried a hand at this new class, simple stuff actually. I created a thread&amp;nbsp;from the button click handler on a winform app and updated a control from the thread method (through anymymous method&amp;nbsp;in this case). This is the snippet &lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;I tried:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;private&amp;nbsp;void&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;button1_Click(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;object&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;sender,&amp;nbsp;EventArgs&amp;nbsp;e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ctx&amp;nbsp;=&amp;nbsp;SynchronizationContext.Current;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New"&gt;//&amp;nbsp;thanks&amp;nbsp;to&amp;nbsp;anonymous&amp;nbsp;methods,&amp;nbsp;everything&amp;nbsp;here&amp;nbsp;is&amp;nbsp;inline&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;thanks&amp;nbsp;to&amp;nbsp;me,&amp;nbsp;this&amp;nbsp;is&amp;nbsp;confusing&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;ThreadPool.QueueUserWorkItem(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;delegate&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;object&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;state)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New"&gt;//&amp;nbsp;would&amp;nbsp;be&amp;nbsp;true&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;Debug.WriteLine(Thread.CurrentThread.IsThreadPoolThread.ToString());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ctx.Send(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;delegate&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;object&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;someState)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New"&gt;//&amp;nbsp;would&amp;nbsp;be&amp;nbsp;false&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;label1.Text&amp;nbsp;=&amp;nbsp;Thread.CurrentThread.IsThreadPoolThread.ToString();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;null&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);&lt;BR&gt;}&lt;BR&gt;&lt;/DIV&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;STRONG&gt;Send &lt;/STRONG&gt;is the method of the SynchronizationContext class&amp;nbsp;to dispatch the method on the right thread synchronously. To do the same asynchronously, we call &lt;STRONG&gt;Post. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Another interesting thing to note is - in .NET 2.0, if you update a control on the wrong thread, you get an InvalidOperationException. As of 1.1, there was no exception, but the result was unpredicatable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;As you might have already guessed, there is not much documentation yet. But, unlike ContextBoundObject, ContextAttribute and other related classes, you might be seeing a lot of articles and proper documentation in the near future. At least, I shall spelunk a little more and come with an article of sorts.&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=74120" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Small, but useful additions in .NET 2.0 – Part 1</title><link>http://msmvps.com/blogs/manoj/archive/2005/10/27/73069.aspx</link><pubDate>Thu, 27 Oct 2005 04:31:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:73069</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=73069</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/10/27/73069.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;The BCL in .NET 2.0 has a plethora of small additions, which are not that visible, but are very useful. I’ll try to cover many of these in my subsequent posts. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;STRONG&gt;String.IsNullOrEmpty&lt;/STRONG&gt; is one such method. As the name would indicate, this method returns true if the string argument passed to this method is either null (nothing in VB) or empty.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;VB 2005 has some good additions too. Among others, I like the &lt;STRONG&gt;IsNot&lt;/STRONG&gt; operator. How much more did you want this operator after writing code like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;If Not obj Is Nothing&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT color=#000080&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;..&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Then&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Now,&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;If &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;obj IsNot Nothing …looks much better.&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=73069" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>SetMaxThreads: A good addition to the ThreadPool class in 2.0</title><link>http://msmvps.com/blogs/manoj/archive/2005/10/06/69175.aspx</link><pubDate>Thu, 06 Oct 2005 14:18:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:69175</guid><dc:creator>Manoj G</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=69175</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/10/06/69175.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;The &lt;STRONG&gt;ThreadPool&lt;/STRONG&gt; class is very handy to developers. You could queue a method to run on a separate thread and forget about it, without worrying about managing the thread object or about a possible thread explosion scenario. That&amp;#8217;s because the .NET ThreadPool keeps a tab on the number of executing threads, which I believe is a maximum of 25 per processor. This might sound just fine, but recently, I came across a situation where even 25 threads per processor looked expensive &amp;#8211; I needed to limit the count to something like 10. Unfortunately, the ThreadPool class didn&amp;#8217;t give me a method/property where I could set a thread count in the pool to something smaller.&amp;nbsp; I wasn&amp;#8217;t adept enough to host the CLR, where I could tweak this count. Instead, I decided to write a simplistic wrapper over the ThreadPool class, which basically did these things:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Keep a count on the number of active threads (which I wanted to limit in the first place)&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Maintain a queue to store requests is threads aren&amp;#8217;t available &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;A timer implementation, where a thread periodically checks whether queued jobs can now be pushed to the thread pool &lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Quite obviously, this is a logical replica of the ThreadPool implementation itself, which is pretty wasteful. But that was until .NET Framework 1.1. In .NET 2.0, the ThreadPool class comes with this new method called &lt;STRONG&gt;SetMaxThreads&lt;/STRONG&gt; &amp;#8211; just what I craved for. You can use this to set the maximum number threads in the thread pool. There are two values to set here &amp;#8211; one for the worker threads (which is more relevant in my case), and one for IO Port completion (this is useful for asynchronous IO operations). &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Again, it is one's responsibility not to set an arbitrary high value of worker threads; Do I need to explain why?&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=69175" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>DataSets - A journey from a boon, to a bane and back</title><link>http://msmvps.com/blogs/manoj/archive/2005/10/04/DataSets-_2D00_-A-journey-from-a-boon_2C00_-to-a-bane-and-back.aspx</link><pubDate>Tue, 04 Oct 2005 09:31:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:68888</guid><dc:creator>Manoj G</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=68888</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/10/04/DataSets-_2D00_-A-journey-from-a-boon_2C00_-to-a-bane-and-back.aspx#comments</comments><description>&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font face="Verdana"&gt;&lt;font color="#000080"&gt;One of the biggest cribs about the DataSet in .NET 1.0 and 1.1 was its serialization performance. The DataSet, albeit providing a rich object model to work with data in a disconnected way, was a bane when it came to passing it across tiers of the application, typically in a remoting scenario. It turned out that in this scenario, the DataSet serialization glutted on bandwidth, memory and CPU cycles. Developers who were hell bent on using the DataSet eventually became the undisputed champions of object serialization, using wonky ways to serialize the dataset in an effort to make it optimal. Less nerdy developers adopted not so adventurous means like using custom collections and arrays, but sacrificing the high-fidelity object model of the DataSet in the process. &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font color="#000080" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font face="Verdana"&gt;&lt;font color="#000080"&gt;Someone said that every complex problem has a simple solution, and .NET 2.0 is turning out to be an angel to this end. As you might have already guessed, the voice from the sky is in form of a new property of the DataSet (and surprise, DataTable too) called &lt;strong&gt;RemotingFormat&lt;/strong&gt;, which is an enumeration of type &lt;strong&gt;SerializationFormat&lt;/strong&gt; having two members &amp;ndash; Binary and Xml. Quite obviously, the default is Xml, to preserve backward compatibility. &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font color="#000080" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font face="Verdana"&gt;&lt;font color="#000080"&gt;Okay, I am digressing slightly here to note something interesting. The name of the property in discussion is RemotingFormat, not something like SerializationFormat or SerializedAs. I suppose, it is to enunciate two things:&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font face="Verdana"&gt;&lt;font color="#000080"&gt;DataSets (and now, even DataTable) implements &lt;strong&gt;IXmlSerializable&lt;/strong&gt;, which is what the XmlSerializer looks for when serializing objects in the web service scenario. So, setting the RemotingFormat property there would&amp;nbsp;be of no consequence, and it does not make sense there either. &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font face="Verdana"&gt;&lt;font color="#000080"&gt;Perhaps, DataSets are more apt for remoting scenarios, as compared to that of Web Services. This is not to say DataSets are deemed not usable in web services (as the implementation of IXmlSerializable would clarify). It is just that all the performance issues discussed earlier in this post would still apply in this case. &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;font color="#000080" face="Verdana"&gt;Finally, I would urge you to read &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/msdnmag/issues/04/10/CuttingEdge/"&gt;&lt;font color="#0000ff" face="Verdana"&gt;&lt;strong&gt;this excellent article&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;font color="#000080" face="Verdana"&gt; by Dino Esposito to get a better insight into this new feature and other improvements that have been added to the DataTable class as well. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=68888" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>Stopwatch your code!</title><link>http://msmvps.com/blogs/manoj/archive/2005/09/27/68047.aspx</link><pubDate>Tue, 27 Sep 2005 13:46:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:68047</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=68047</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/09/27/68047.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT color=#000080&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;Timing managed code is one thing I do quite often. I guess measurement of the method level execution times is a common task for any application developer for that matter. I have used various methods for measurement; the worst of them all is using DateTime. DateTime simply does not give you that high resolution timing. The alterative was to use a couple of Win32 API called &lt;/SPAN&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;QueryPerformanceCounter &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;and&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt; QueryPerformanceFrequency. &lt;/SPAN&gt;&lt;/B&gt;If you have used MS Enterprise Library, you would see that the &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;Microsoft.Practices.EnterpriseLibrary.Logging.Tracing.Tracer&lt;/SPAN&gt;&lt;/B&gt; class uses these API for timing. There is a small catch in the implementation though. Since P/Invoke is involved here, every call would result in &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;UnManagedCode&lt;/SPAN&gt;&lt;/B&gt; permission being demanded. The stack walk thus performed results in some loss in the resolution of the timing. Therefore, it is fair enough to mark the native method helpers with the &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;SPAN&gt;SuppressUnmanagedCodeSecurityAttribute. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;SPAN&gt;&lt;FONT color=#000080&gt;This attribute ensures that the permission demand happens only at link time (JIT compile time), and not for subsequent calls. If you are well aware of the security implications of this attribute usage, you are ready to go. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;Okay wait, don’t go far implementing all what I said earlier; &lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;System.Diagnostics.Stopwatch&lt;/SPAN&gt;&lt;/B&gt; in .NET 2.0 gives you just that. Here’s a snippet:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;Stopwatch&amp;nbsp;watch&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;new&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;Stopwatch();&lt;BR&gt;watch.Start();&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New"&gt;//&amp;nbsp;Some&amp;nbsp;operation&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;watch.Stop();&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New"&gt;int&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New"&gt;elapsedTime&amp;nbsp;=&amp;nbsp;watch.ElapsedMilliseconds;&lt;BR&gt;&lt;/DIV&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-weight: bold"&gt;&lt;FONT color=#000080&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT color=#000080&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;The best part of about the Stopwatch class is that it intelligently uses a resolution based on whether the underlying hardware supports a high one or not (&lt;/SPAN&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;B&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;QueryPerformanceFrequency &lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;API returns true if high resolution is supported&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;). If not supported, the Stopwatch reverts to that provided by DateTime. You can query the &lt;STRONG&gt;IsHighResolution&lt;/STRONG&gt; static property to find out whether high resolution is supported on your machine.&amp;nbsp;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT color=#000080&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=68047" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>InternalsVisibleToAttribute - Friend Assemblies</title><link>http://msmvps.com/blogs/manoj/archive/2005/09/26/67999.aspx</link><pubDate>Mon, 26 Sep 2005 16:24:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:67999</guid><dc:creator>Manoj G</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=67999</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/09/26/67999.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;You come across several situations where you need to develop a set of class libraries, say a framework of sorts, and there are several classes within certain assemblies which need to be marked as internal. You go ahead and mark them as internal, and then realize that there are other classes, within the framework, which are dependent on these marked classes, but exist in other assemblies. This is a problem, and you have no choice – you mark these classes as public and then document that the particular class should not be used directly from the code. You may think that this is a bad design, in a way, but there are no shortage of these in the .NET BCL. How often do you come across MSDN documentation which reads something like:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;"This class supports the .NET Framework infrastructure and is not intended to be used directly from your code."?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Ideally, these should have been internal classes, but you simply cannot have them that way. &lt;STRONG&gt;StrongNameIdentityPermission &lt;/STRONG&gt;provides an alternative, but it isn’t always practical.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;In .NET Framework 2.0, there exists a decent workaround to this problem. A new attribute called &lt;STRONG&gt;InternalsVisibleToAttribute&lt;/STRONG&gt; has been introduced, which when applied to an assembly indicates that all internal types in that assembly would be visible to another assembly, whose name is specified in the attribute constructor. In other words, that assembly becomes a friend assembly. The usage would be something like: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;[assembly:InternalsVisibleToAttribute("MyFriendAssembly”)]&lt;BR&gt;Or (for a strong-named friend)&lt;BR&gt;[assembly:InternalsVisibleToAttribute("MyFriendAssembly, PublicKeyToken=45cb56a45e0a69a1")]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Don’t get carried away, refer &lt;A href="http://msdn2.microsoft.com/library/0tke9fxk(en-us,vs.80).aspx"&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;to this MSDN section&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt; to know more about the constraints and other considerations while using this attribute.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Now, what could be the usage scenarios for this attribute? I have already explained one such scenario in the earlier sections of this post. Another case may be that of unit test assemblies. Typically, we keep unit tests in separate assemblies. Now, to be able to test all the internal classes/methods, it would be useful to gain visibility into them. So, we may declare the unit-test assembly as a friend of the actual assembly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;[Digression: Adroit users of VS 2005 may quickly pounce upon the last use. VS 2005 unit testing framework provides reflection-based helpers which help you write tests against non-public members of a class. So, it’s left to you to decide which a better choice is]&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=67999" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>HttpListener in .NET 2.0 - Creating new possibilities</title><link>http://msmvps.com/blogs/manoj/archive/2005/07/10/56839.aspx</link><pubDate>Sat, 09 Jul 2005 20:28:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:56839</guid><dc:creator>Manoj G</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=56839</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2005/07/10/56839.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Microsoft's vision of the .NET Framework was a that of a platform for developing Web Services; the primary motivation behind this inception being ease and productivity for developers, and performance and scalability for the deployed applications. Developers have been leveraging the .NET Framework to develop Web Services in the form of ASMX. So much are the productivity benefits of ASMX, that developers are more or less absolved from the nitty-gritties of SOAP, WSDL and XML Schema.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;In the recent times, a new revolution has been dawning in the form of Service Orientation, and Service Oriented Architecture (SOA) seems to be the talk of the town. SOA is about seeing the world as collaborating services, which are autonomous in nature, and communicate with each other through messages. The format of this exchange is governed by a contract and the compatibility by a policy.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Now, my very brief introduction to ASMX followed by a short note on SOA may seem logical to many. To many developers, SOA and Web Services (a.k.a. ASMX) are synonymous. However, a perusal of the core tenets of SOA would draw the line between the two quite clearly. You would then agree that ASMX is just a way of realizing SOA, nothing more. As much as ASMX lends itself towards SOA, it has one big constraining factor - it is currently appears tied to IIS. This, in a way, takes us away from the notion of ubiquitous "services" in an SOA scheme. In my opinion, SOA requires every conceivable type of application to be inherently capable of exchanging messages using standards like SOAP and HTTP. In other words, applications should be capable of hosting ASMX without having to rely on the services of IIS.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;For an application to host ASMX, two things need to be in place: An HTTP listener which can cater to HTTP requests on ports 80 and 443, and the ability to host the ASP.NET's HTTP runtime infrastructure, which is used by ASMX. Now, of the two, the second requirement is already available in ASP.NET 1.1 in the form of classes in&amp;nbsp;System.Web and System.Web.Hosting namespaces. Infact, ASMX was designed from the ground up to be decoupled from IIS. So, the only void at this point is that of an HTTP listener. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Come .NET 2.0 and this need is well addressed. Starting with Whidbey, and running up to the Indigo timeframe, any application would be capable of hosting ASMX, made easy by a few managed classes like HttpListerner. This ability opens the door for a multitude of possibilities and easier ways to realize SOA. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;H&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;opefully, this news has got you exited and left you begging for more technical details. With this note, I would leave it over to this excellent (as always)&amp;nbsp;article from Aaron Skonnard, one of my favorite authors: &lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#0000ff size=2&gt;&lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/default.aspx"&gt;Service Station: Run ASMX Without IIS &lt;/A&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=56839" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>DBProviderFactory - Old wine in a new bottle, but good nonetheless</title><link>http://msmvps.com/blogs/manoj/archive/2004/08/02/DBProviderFactory-_2D00_-Old-wine-in-a-new-bottle_2C00_-but-good-nonetheless.aspx</link><pubDate>Mon, 02 Aug 2004 13:40:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:11107</guid><dc:creator>Manoj G</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=11107</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2004/08/02/DBProviderFactory-_2D00_-Old-wine-in-a-new-bottle_2C00_-but-good-nonetheless.aspx#comments</comments><description>&lt;p&gt;&lt;font color="#000080"&gt;&lt;font face="Verdana" size="2"&gt;Quite a while back, I had posted an article in CodeProject titled &amp;quot;&lt;/font&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;font color="#0000ff" face="Verdana"&gt;&lt;a href="http://www.codeproject.com/vb/net/data_access_layer.asp"&gt;Implementing a Provider Independent Data Access Layer in .NET&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font face="Verdana"&gt;&amp;quot;. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;This article illustrated the usage of a simple provider factory, with which data access could be made generic or provider independent. The implementation was rather straight forward. &lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;Callers of the DAL (Data Access Layer) component would work only with Interfaces present in the &lt;strong&gt;System.Data&lt;/strong&gt; namespace. &lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;The actual type of provider to be used in the DAL code would be determined through a config file setting and the provider factory would be responsible for returning instances of the required type .&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080"&gt;&lt;font face="Verdana" size="2"&gt;The advantage of this methodology is that it gives you the option of (almost) seamlessly working with multiple providers like OleDb and ODBC without having to lock onto to a specific implementation like SQLClient. With the obvious advantage and seemingly simple implementation, we all could expect a provider factory to be built into the next version of ADO.NET. Well, ADO.NET 2.0 is here and with it comes the &lt;/font&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;&lt;strong&gt;DbProviderFactory &lt;/strong&gt;class&lt;strong&gt;. &lt;/strong&gt;The implementation is fundamentally similar to the factory we discussed in my article but, there are a few important differences: &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;Foremost among them is that DbProviderFactory itself is an abstract base class and every provider must provide an implementation for this. The provider to use at runtime is obtained by calling the &lt;strong&gt;GetFactory &lt;/strong&gt;static method of the &lt;strong&gt;DbProviderFactories &lt;/strong&gt;class by passing a string uniquely representing that provider&lt;strong&gt;. &lt;/strong&gt;This string is called &lt;strong&gt;Provider Invariant Name &lt;/strong&gt;and is registered by each provider in &lt;strong&gt;machine.config&lt;/strong&gt;. For e.g. for ODBC provider, it is&lt;strong&gt; System.Data.Odbc&lt;/strong&gt;. &lt;/font&gt;&lt;font color="#800080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#800080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#800080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#800080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#800080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;The second important difference is that the new provider model is based on inheritance of a set of base classes present in the &lt;strong&gt;System.Data.Common &lt;/strong&gt;namespace. So, you have &lt;strong&gt;SqlConnection &lt;/strong&gt;derived from &lt;strong&gt;DbConnection &lt;/strong&gt;and so on. However, various IdbInterfaces we saw in v1.0 and&amp;nbsp;v1.1 would still be implemented for backward compatibility. I believe the reason behind this change is that ADO.NET classes will constantly evolve to provide more features in terms of properties, methods and events. Exposing the functionality through interfaces can be an overkill in terms of maintenance in the future, wherein you maintain backward compatibility by retaining the old interface implementation, while you add new functionality by implementing new ones (analogous to COM).&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;&lt;font color="#000080"&gt;For more information on DbProviderFactory, I would really recommend a good article recently published at MSDN : &lt;strong&gt;&lt;font color="#0000ff"&gt;&lt;a href="http://msdn.microsoft.com/data/default.aspx?pull=/library/en-us/dnvs05/html/vsgenerics.asp"&gt;&lt;font color="#0000ff"&gt;Generic Coding with the ADO.NET 2.0 Base Classes and Factories&lt;/font&gt;&lt;/a&gt;. &lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;This article explains in detail, all the stuff that I mentioned briefly earlier, with a fair amount of examples too.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;Ofcourse, there is a lot more to ADO.NET 2.0 than the ProviderFactory. For a fairly detailed listing refer to&lt;strong&gt; &lt;/strong&gt;&lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;&lt;a href="http://msdn.microsoft.com/data/default.aspx?pull=/library/en-us/dnvs05/html/ado2featurematrix.asp"&gt;&lt;font color="#0000ff"&gt;ADO.NET 2.0 Feature Matrix&lt;/font&gt;&lt;/a&gt;. &lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;Things that catch some interest here are Provider Statistics and improvements of SQLClient wrt SQL Server 2005.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080" face="Verdana" size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=11107" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item><item><title>My real peek at VB 2005!</title><link>http://msmvps.com/blogs/manoj/archive/2004/07/22/10475.aspx</link><pubDate>Thu, 22 Jul 2004 11:16:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:10475</guid><dc:creator>Manoj G</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/manoj/rsscomments.aspx?PostID=10475</wfw:commentRss><comments>http://msmvps.com/blogs/manoj/archive/2004/07/22/10475.aspx#comments</comments><description>&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;FONT color=#000080&gt;My start with VS 2005 has rather been a bit sluggish. I didn&amp;#8217;t really work much with the Community Tech Preview, but when I got the Beta 1, I decided to get my hands real dirty with it. At about the same time, I cam across a few excellent resources at MSDN (especially, &lt;B&gt;&lt;A href="http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/vbnet2005_preview.asp"&gt;&lt;FONT color=#0000ff&gt;A Sneak Preview of Visual Basic 2005&lt;/FONT&gt;&lt;/A&gt;). &lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000080 size=2&gt;All the new enhancements are great and do take developer productivity to a new high. But its worth mentioning about my top picks (of today):&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;U&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;ClickOnce&lt;/FONT&gt;&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;I must say my most favorite of the all features in .NET 2.0 is ClickOnce Installation. The concept of Smart Client is indeed revolutionary, because it brings together the best of the two worlds : Easy deployment model of thin clients and Rich UI of the thick client applications. The earlier version of .NET gave a good headstart in this direction, but was littered by limitations that definitely needed to be addressed. ClickOnce does just that. These are the salient features:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Easily configure and publish applications from the VS IDE. You can even use a friendly wizard for this purpose.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Applications can now be configured for offline access. Applications are actually installed on the machine with entries made to Add/Remove Programs snap-in&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Applications can now Auto-Update themselves when newer updates are available.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;For more info on ClickOnce, refer to &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/04/05/ClickOnce/default.aspx"&gt;&lt;FONT face=Verdana color=#0000ff size=2&gt;&lt;STRONG&gt;this MSDN Mag Article &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&amp;nbsp;and this &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20040108ClickOnceJC/manifest.xml"&gt;&lt;FONT face=Verdana color=#0000ff size=2&gt;&lt;STRONG&gt;MSDN TV Presentation&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana color=#000080 size=2&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;U&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Edit And Continue [EnC]&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;An uproar is always in the making if a great feature exists in a previous version is not available in the next. Well, that was the case with Edit and Continue, a feature loved and used by VB devs in the past. So much so, that a lot VB6 friends I know of, actually develop only in the VB6 debugger! In VB6, as you all know, applications are compiled into P-Code (Pseudo Code) and not native code in debug mode. So, under the VB debugger, the code would be interpreted (highly simplified). &lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;It may be naive thinking, but I wonder how the CLR team pulled this one off. I am sure the seemingly simple EnC would be a really hard thing to be implemented. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;EnC however, does not make its way into C#. &lt;A href="http://blogs.msdn.com/andypennell/archive/2004/02/03/66949.aspx"&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Andy Pennel's[MS] blog entry&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;and &lt;A href="http://blogs.msdn.com/jaybaz_ms/archive/2004/05/17/133402.aspx"&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;JayBaz's [MS] entry&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;STRONG&gt; &lt;/STRONG&gt;give more insight into why this was dropped from C#. Nice posts, don&amp;#8217;t miss the comments as well !&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;ASP.NET also doesn&amp;#8217;t have EnC as such but supports &amp;#8220;Save and Refresh&amp;#8221; style of debugging. Have look at &lt;A href="http://blogs.msdn.com/bgold/archive/2004/04/19/115954.aspx"&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Brian Goldfarb's entry&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt; on why this was elided in ASP.NET .&lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000080&gt;&lt;FONT face=Verdana&gt;&lt;B&gt;&lt;U&gt;Code Snippets (VB 2005)&lt;/U&gt;&lt;/P&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;This is a real cool feature provided by VB IDE. Through this feature, you can insert code snippets of very commonly used development tasks like creating a file etc into the code by using the context menu. C# does not however, have such an extensive set of snippets and I couldn&amp;#8217;t find ways to add my own as I could do with the VB IDE.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;One notable absence in VB 2005 is &lt;STRONG&gt;Refactoring&lt;/STRONG&gt;. Paul Vick, in &lt;A href="http://www.panopticoncentral.net/archive/2003/10/31/233.aspx"&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;one of his posts&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt; explains. &lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;It's pretty funny, but many say that Refactoring is somewhat of a "grunge thing" that an average VB developer would not be too bothered about and hence better left out. &lt;/FONT&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;I don&amp;#8217;t agree with that. I feel refactoring, just like designing, is an art, and it would be great to have the support in the IDE. If you have worked with &lt;STRONG&gt;&lt;A href="http://www.jetbrains.com/resharper/"&gt;&lt;FONT color=#0000ff&gt;ReSharper&lt;/FONT&gt;&lt;/A&gt;&lt;/STRONG&gt;, you would know why. I may not be too experienced to completely know VB's philosophy, but I can say that &amp;#8220;Keep things simple&amp;#8221; and &amp;#8220;Make stuff easier&amp;#8221; have been the prime&amp;nbsp;doctrines of VB. Now, the thing to ponder about is - doesnt refactoring fit into one of these isms of VB ?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=10475" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/manoj/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category></item></channel></rss>