James Michael Hare

...hare-brained ideas from the realm of software development...
posts - 136 , comments - 1093 , trackbacks - 0

My Links

News

Welcome to my blog! I'm a Sr. Software Development Engineer in Seattle, WA. I've been doing C++/C#/Java development for over 18 years, but have definitely learned that there is always more to learn!

All thoughts and opinions expressed in my blog and my comments are my own and do not represent the thoughts of my employer.

Blogs I Read

MCC Logo MVP Logo

Follow BlkRabbitCoder on Twitter

Tag Cloud

Archives

Post Categories

Microsoft

There are 24 entries for the tag Microsoft
C#/.NET Little Wonders – The DateTimeOffset struct
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Anyone who has done any .NET programming has most likely used the DateTime structure at one time or another in their development. It is a handy structure for storing dates, times, or date-times relating to the local time zone (or, alternatively, UTC). That said, ......

Posted On Thursday, March 8, 2012 6:37 PM | Comments (1) | Filed Under [ My Blog ]

C#/.NET Fundamentals: Safely and Efficiently Raising Events
The C#/.NET Fundamentals series is geared towards examining fundamental concepts in using C# (and .NET in general) to produce effective solutions. A couple of posts ago, I discussed the EventHandler<TEventArgs> and EventHandler delegates, and in particular at one point mentioned in a sidebar that you need to watch out for thread-safety in order to safely raise events in a multi-threaded environment. There was an interesting discussion in the comments about different ways that people achieve ......

Posted On Thursday, December 1, 2011 8:10 PM | Comments (15) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The EventHandler and EventHandler<TEventArgs> delegates
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. In the last two weeks, we examined the Action family of delegates (and delegates in general), and the Func family of delegates and how they can be used to support generic, reusable algorithms and classes. So this week, we are going to look at a handy pair of delegates ......

Posted On Thursday, November 17, 2011 7:20 PM | Comments (9) | Filed Under [ My Blog ]

C#/.NET Little Wonders: TPL Wonders - The Parallel.For() Method
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Previously, I had created some posts about the Task Parallel Library’s Concurrent Collections – which are very efficient collections designed for concurrent use with minimal contention – but in this next series of Little Wonders posts, I’d like to explore the parts ......

Posted On Thursday, October 20, 2011 7:43 PM | Comments (3) | Filed Under [ My Blog ]

C#/.NET Little Wonders: String Padding and Trimming - Not Just for Spaces!
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders post can be found here. This post continues a series of Little Wonders in the BCL String class. Yes, we all work with strings in .NET daily, so perhaps you already know most of these. However, there are a lot of little fun things that the String class can do that often get overlooked. ......

Posted On Thursday, September 22, 2011 6:27 PM | Comments (7) | Filed Under [ My Blog ]

Visual C# MVP, 2011
I was informed on July 1st, 2011 that I was awarded a Microsoft Visual C# MVP recognition for 2011. I'm very thankful to have been nominated and selected, and thankful that you guys all find my posts informative and useful! I'll try my best to keep up the good work! Thanks to everyone! Tweet Technorati Tags: .NET, C#, MVP ......

Posted On Wednesday, July 13, 2011 8:06 PM | Comments (9) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The Nullable static class
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Today we’re going to look at an interesting Little Wonder that can be used to mitigate what could be considered a Little Pitfall. The Little Wonder we’ll be examining is the System.Nullable static class. No, not the System.Nullable<T> class, but a static ......

Posted On Thursday, June 30, 2011 6:52 PM | Comments (4) | Filed Under [ My Blog ]

C#/.NET Fundamentals: Choosing the Right Collection Class
The .NET Base Class Library (BCL) has a wide array of collection classes at your disposal which make it easy to manage collections of objects. While it's great to have so many classes available, it can be daunting to choose the right collection to use for any given situation. As hard as it may be, choosing the right collection can be absolutely key to the performance and maintainability of your application! This post will look at breaking down any confusion between each collection and the situations ......

Posted On Thursday, June 16, 2011 7:11 PM | Comments (55) | Filed Under [ My Blog ]

Tech Ed 2011 Atlanta – It’s Good to Be an Alumni
Woke up this morning and decided to finally stop by the Alumni Lounge. I had been meaning to check it out, but I had been so busy with such great presentations and hanging out in the Blogger’s Lounge that I never got around to it. I truly wish I had stopped in sooner! There’s nice bottles of soda with glasses for ice so you can have it nice and cold as well as a hot beverage bar. And this morning there were delicious cinnamon rolls (the nemesis of my beltline, alas!) and other treats and candies. ......

Posted On Wednesday, May 18, 2011 10:26 AM | Comments (1) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The ElementAt() and Last() Extension Methods
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. Most of my time this week has been spent finishing the current iteration at work and updating a presentation for the Springfield DNUG, so today’s post will be a bit on the lighter side, but I wanted to continue my post series so I thought it would be a good time to quickly mention the ElementAt() and Last() LINQ extension methods. ......

Posted On Thursday, April 28, 2011 7:35 PM | Comments (4) | Filed Under [ My Blog ]

C#/.NET Little Wonders: ConcurrentBag and BlockingCollection
In the first week of concurrent collections, began with a general introduction and discussed the ConcurrentStack<T> and ConcurrentQueue<T>. The last post discussed the ConcurrentDictionary<T> . Finally this week, we shall close with a discussion of the ConcurrentBag<T> and BlockingCollection<T>. For more of the "Little Wonders" posts, see C#/.NET Little Wonders: A Redux. Recap As you'll recall from the previous posts, the original collections were object-based containers ......

Posted On Thursday, March 3, 2011 6:56 PM | Comments (9) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The ConcurrentDictionary
Once again we consider some of the lesser known classes and keywords of C#. In this series of posts, we will discuss how the concurrent collections have been developed to help alleviate these multi-threading concerns. Last week’s post began with a general introduction and discussed the ConcurrentStack<T> and ConcurrentQueue<T>. Today's post discusses the ConcurrentDictionary<T> (originally I had intended to discuss ConcurrentBag this week as well, but ConcurrentDictionary had enough ......

Posted On Thursday, February 17, 2011 6:00 PM | Comments (17) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The ConcurrentStack and ConcurrentQueue
Once again we consider some of the lesser known classes and keywords of C#. In the next few weeks, we will discuss the concurrent collections and how they have changed the face of concurrent programming. This week’s post will begin with a general introduction and discuss the ConcurrentStack<T> and ConcurrentQueue<T>. Then in the following post we’ll discuss the ConcurrentDictionary<T> and ConcurrentBag<T>. Finally, we shall close on the third post with a discussion of the ......

Posted On Thursday, February 10, 2011 7:30 PM | Comments (3) | Filed Under [ My Blog ]

C#/.NET Little Wonders: The Useful But Overlooked Sets
Once again we consider some of the lesser known classes and keywords of C#. Today we will be looking at two set implementations in the System.Collections.Generic namespace: HashSet<T> and SortedSet<T>. Even though most people think of sets as mathematical constructs, they are actually very useful classes that can be used to help make your application more performant if used appropriately. For more of the "Little Wonders" posts, see the index here. A Background From Math In mathematical ......

Posted On Thursday, February 3, 2011 6:23 PM | Comments (13) | Filed Under [ My Blog ]

C# Toolbox: A Debuggable, Self-Installing Windows Service Template (1 of 2)
Update: I have now placed the zip containing the source for the end result of part 1 and 2 of this service template here. I decided to write a pair of posts on making it easier to create Windows Services in C# (and in .NET in general). This is the first post that talks about how to make a Windows Service debuggable (the default visual studio template does not allow the service to be easily debugged), and then next week’s post will discuss making the Windows Service self-installing. Now, these posts ......

Posted On Thursday, September 23, 2010 5:59 PM | Comments (6) | Filed Under [ My Blog ]

C#/.NET Five Final Little Wonders That Make Code Better (3 of 3)
This week is my final entry in my Little Wonders series (posts one and two are here and here). These are those little tips and tricks in .NET (and in particular C#) that may not seem like much, but can help make your code either more concise, maintainable, or performant. Thanks again for all your comments and suggestions on this series, it has been a lot of fun to write, and though I feel I could go on forever with lots more tips and tricks, this will be the last Little Wonders post for a while. ......

Posted On Thursday, September 9, 2010 6:06 PM | Comments (33) | Filed Under [ My Blog ]

C# Fundamentals: Parameters Passing Nuances
Last week I went into quite a bit of detail on C# struct (here) and the consequences of using a struct versus a class to represent complex data types. In the course of that article, I had a section describing the differences between value types and reference types and thought I would expand upon one of the ideas in there which seems to confuse some folks who are new to C#: parameter passing nuances. But first, let's lay the groundwork with some definitions: Parameter - the variable defined in a method ......

Posted On Thursday, August 5, 2010 6:18 PM | Comments (1) | Filed Under [ My Blog ]

C# Fundamentals: Optional Parameters - Pros and Pitfalls
When Microsoft rolled out Visual Studio 2010 with C# 4, I was very excited to learn how I could apply all the new features and enhancements to help make me and my team more productive developers. Default parameters have been around forever in C++, and were intentionally omitted in Java in favor of using overloading to satisfy that need as it was though that having too many default parameters could introduce code safety issues. To some extent I can understand that move, as I’ve been bitten by default ......

Posted On Thursday, June 17, 2010 6:11 PM | Comments (5) | Filed Under [ My Blog ]

Premature-Optimization and Performance Anxiety
While writing my post analyzing the new .NET 4 ConcurrentDictionary class (here), I fell into one of the classic blunders that I myself always love to warn about. After analyzing the differences of time between a Dictionary with locking versus the new ConcurrentDictionary class, I noted that the ConcurrentDictionary was faster with read-heavy multi-threaded operations. Then, I made the classic blunder of thinking that because the original Dictionary with locking was faster for those write-heavy uses, ......

Posted On Sunday, June 13, 2010 8:42 PM | Comments (1) | Filed Under [ My Blog ]

A Good Developer is So Hard to Find
Let me start out by saying I want to damn the writers of the Toughest Developer Puzzle Ever – 2. It is eating every last shred of my free time! But as I've been churning through each puzzle and marvelling at the brain teasers and trivia within, I began to think about interviewing developers and why it seems to be so hard to find good ones. The problem is, it seems like no matter how hard we try to find the perfect way to separate the chaff from the wheat, inevitably someone will get hired who falls ......

Posted On Wednesday, June 2, 2010 9:09 PM | Comments (1) | Filed Under [ My Blog ]

C#: Does an IDisposable in a Halted Iterator Dispose?
If that sounds confusing, let me give you an example. Let's say you expose a method to read a database of products, and instead of returning a List<Product> you return an IEnumerable<Product> in iterator form (yield return). This accomplishes several good things: The IDataReader is not passed out of the Data Access Layer which prevents abstraction leak and resource leak potentials. You don't need to construct a full List<Product> in memory (which could be very big) if you just want ......

Posted On Tuesday, May 4, 2010 7:52 PM | Comments (2) | Filed Under [ My Blog ]

C# Extension Methods - To Extend or Not To Extend...
I've been thinking a lot about extension methods lately, and I must admit I both love them and hate them. They are a lot like sugar, they taste so nice and sweet, but they'll rot your teeth if you eat them too much. I can't deny that they are useful and handy. After all, one of the major components of the Shared Component library where I work is a set of useful extension methods to help simplify common repetitive tasks. But, I also can't deny that they tend to be overused and abused to willy-nilly ......

Posted On Monday, April 26, 2010 10:44 PM | Comments (20) | Filed Under [ My Blog ]

C#: LINQ vs foreach - Round 1.
So I was reading Peter Kellner's blog entry on Resharper 5.0 and its LINQ refactoring and thought that was very cool. But that raised a point I had always been curious about in my head -- which is a better choice: manual foreach loops or LINQ? The answer is not really clear-cut. There are two sides to any code cost arguments: performance and maintainability. The first of these is obvious and quantifiable. Given any two pieces of code that perform the same function, you can run them side-by-side and ......

Posted On Friday, April 23, 2010 6:54 AM | Comments (30) | Filed Under [ My Blog ]

C#: A "Dumbed-Down" C++?
I was spending a lovely day this last weekend watching my sons play outside in one of the better weekends we've had here in Saint Louis for quite some time, and whilst watching them and making sure no limbs were broken or eyes poked out with sticks and other various potential injuries, I was perusing (in the correct sense of the word) this month's MSDN magazine to get a sense of the latest VS2010 features in both IDE and in languages. When I got to the back pages, I saw a wonderful article by David ......

Posted On Sunday, April 18, 2010 11:17 PM | Comments (5) | Filed Under [ My Blog ]

Powered by: