Tag: .NET
Fixing out of sequence timestamps
I maintain a small open source project that helps test log message . Part of this is that each log message has a sequence number and timestamp attached to it....
Why is there a difference between decimal 0 and 0.0?
const decimal ZeroA = 0M; const decimal ZeroB = 0.0M; They're the same thing, right? Well, almost. The equality operator says they're the same thing. bool...
Paramore Brighter: The Russian Doll Model
I've mentioned a bit about the attributing the handler and the step and timing parameters, but I've not explained them properly in previous posts (" Retrying...
Paramore Brighter: DRY with Custom Decorated Command Handlers
You may wish to add similar functionality to many (or all) command handlers. The typical example is logging. You can decorate a command handler in a similar...
Paramore Brighter with Quality of Service: Retrying Commands
Paramore Brighter supports Policies to maintain quality of service. This is useful when your command makes calls to external services, whether they are...
Paramore Brighter: Implementing a fallback exception handler
So far in this series, we have a basic command processor set up and able to dispose of resources . But what happens when things go wrong? The command processor...
Round Robin class
We recently had need of a round robin functionality and since there is no round robin class built into .NET I needed to build my own class. It is a fairly...
But why is the iterator operating in multiple-threads
Background Recently, I had a bit of a problem with NHibernate when I was converting some code into parallel tasks. (If you have no interest in NHibernate, then...
Debugging a process that cannot be invoked through Visual Studio.
Sometimes it is rather difficult to debug through Visual Studio directly even although the project is right there in front of you. In my case I have an...
A better tracing routine
In .NET 4.5 three new attributes were introduced. They can be used to pass into a method the details of the caller and this can be used to create better trace...
Checking for NULL using Entity Framework
Here is a curious gotcha using the Entity Framework: If you are filtering on a value that may be null then you may not be getting back the results you expect....
Handling bounces on Amazon SES
If you send to an email that does not exist, Amazon SES will perform some handling of the bounce before passing the details on to you. When you send email...
Verifying Senders with Amazon SES
I’ve already written a couple of pieces about Amazon Simple Email Service (SES) on sending Email and sending emails with attachments . Why do you have to...
Sending more than a basic email with Amazon SES
Previously, I wrote about getting started with Amazon’s Simple Email Service , and I included details of how to send a basic email. The SendEmail method is...
First(OrDefault) Vs. Single(OrDefault)
There are two mechanisms (each with an …OrDefault variant) in LINQ for getting one item out of an enumeration. They are First and Single . There is a...
Tip of the day: Expire a cookie, don’t remove it
I recently found a bug in my code that I couldn’t fathom initially until I walked through the HTTP headers in firebug. In short, you cannot simply remove a...
Tip of the day: Splitting a string when encountering whitespace
In .NET the string class has a Split method that splits the string at the separator character(s) that you specify. However, if you want to split the string at...
Building messages in parallel
I recently saw some code where the developer was attempting to build up messages inside tasks that were being reported outside of the task. In a sequential...
Parallel Tasks and the HttpContext
A few days ago I spotted a question on StackOverflow by someone trying to use a parallel loop in an ASP.NET application. It may have been an ASP.NET MVC...
ASP.NET MVC – Pretty URLs
As the little Harris Benedict Calculator application stands , the only way to get some sort of answer out of it is to fill in the form. What if you wanted to...
ASP.NET MVC 3 – Introduction to validation
In my previous post on MVC 3 I started a project to calculate a calorific intake required to maintain a stable weight. In this post I’ll extent that to add...
ASP.NET MVC – Server Side Validation
So far, we’ve built up a basic application and got some client side validation working. However, client side validation only goes so far. While it can prevent...
Starting an ASP.NET MVC 3 application
In this post, I’m going to show the basics of starting an application with ASP.NET MVC 3. The demo application will be a simple calorie counter that takes in a...
Tip of the day: Obtaining all subdirectories recursively
This is an example of how to obtain a list of all subdirectories using a recursive method with the .NET Framework. public static List<DirectoryInfo>...
Parallelisation Talk Example - Aggregate Exceptions
The two code examples here show what happens when exceptions are thrown within tasks that are not handled within the task. In each case the task that has the...
Parallelisation Talk Example – ConcurrentBag
This example shows a ConcurrentBag being populated and it being accessed while another task is still populating the bag. The ConcurrentBag class can be found...
Parallelisation talk example – Independent Object Graphs
Parallelised code works best when data is not shared. This example shows a simple piece of parallel code where each task operates independently on its own...
Parallelisation Talk Example – Parallel.Invoke
Parallel.Invoke is the most basic way to start many tasks as the same time. The method takes as many Action<…> based delegates as needed. The Task Parallel...
Parallelisation Talk Examples – Basic PLINQ
These are some code examples from my introductory talk on Parallelisation showing the difference between a standard sequential LINQ query and its parallel...
Parallelisation Talk Examples – ConcurrentDictionary
The example used in the talk was one I had already blogged about. The original blog entry the example was based upon is here: Parallelisation in .NET 4.0 – The...
Parallelisation Talk examples - Parallel.For
This is some example code from my introductory talk on Parallelisation. Showing the difference between a standard sequential for loop and its parallel...
Parallelisation Talk Examples – Parallel.ForEach
These are some code examples from my introductory talk on Parallelisation. Showing the difference between a standard sequential foreach loop and its parallel...
Prallelisation Talk Example – Tasks within Tasks
In this example I’m showing the launching of further tasks within an existing task. The Main method launches a single task (of course, it would likely be many...
Building a tag cloud with LINQ
I have a set of blog posts that I’m representing as a List of BlogPost objects. A BlogPost is class I created that represents everything to do with a blog...
Tasks that create more work
I’m creating a program that parses a web page then follows the links and then parses the next set of web pages to eventually build a picture of an entire site....
Using semaphores to restrict access to resources
I’m in the process of building a small data extraction application. It uses the new Parallel Extensions in .NET 4 in order to more efficiently extract data...
Parallelisation in .NET 4.0 - The concurrent dictionary
One thing that I was always conscious of when developing concurrent code was that shared state is very difficult to deal with. It still is difficult to deal...
A quick intro to the HTML Agility Pack
I want a way to extract all the post data out of my blog. To do that I’m building a little application to do that, mostly as an exercise to try out some new...
Parallelisation in .NET 4.0 - Part 2 Throwing Exceptions
With more threads running simultaneously in an application there is increasing complexity when it comes to debugging. When exceptions are thrown you usually...
Parallelisation in .NET 4.0 - Part 1 looping
In an upcoming project we have a need for using some parallelisation features. There are two aspects to this, one is that we have to make multiple calls out to...
Lambda cheat sheet
A while ago I wrote about all the new language features of C# 3.0 and it occurred to me that I'd left out a chunk about Lambdas. With LINQ being such an...
Updated chart of .NET version numbers
Way back when, I published a table detailing the version numbers of the various parts that make up a .NET application: The Tools, the C# language, the...
Tip of the Day: Duplicate input fields
Don't allow duplicate input fields into your form. The other day I was trying to debug a bug in an application that I maintain. The code created a set of...
Tip of the Day: NaN (Not a Number)
The Issue If you want to detect if a double (System.Double) or float (System.Single) is 'not a number' or NaN you cannot use something like this: if (myDouble...
Tip of the day - String Equality
When comparing two strings in a case insensitive manner, use: myFirstString.Equals(mySecondString, StringComparison.InvariantCultureIgnoreCase) or, if cultural...
Crazy Extension Methods Redux (with Oxygene)
Back in April I blogged about a crazy thing you can do with extension methods in C#3.0 . At the time I was adamant that it was a bad idea. I still think it is...
Tip of the Day - String Performance
Concatenating strings in .NET can be very easy. There is the overloaded + operator that makes stringA + stringB + stringC statements very easy to write. But,...
Monitoring change in XML data (LINQ to XML series - Part 5)
This is the 5th part in a series on LINQ to XML. In this instalment we will look at monitoring changes in XML data in the XML classes added to .NET 3.5. The...
Tip of the Day #4 (Connection Strings in Config files)
From .NET 2.0 onwards a new and improved configuration management system has been put in place. You can now add a <connectionString> element to the config file...
Navigating XML (LINQ to XML series - part 4)
In my last few posts on LINQ to XML ( part 1 , part 2 and part 3 ) I've shown you a starter on navigating around XML data. In this post I'll continue to show...
Navigating XML (LINQ to XML series - Part 3)
In my last two posts I've been introducing you to the the new XML classes in .NET 3.5. In this post I'll continue that and show you some...
Fizz-Buzz in LINQ
This just occurred to me. It is somewhat pointless, but I thought it was interesting: static void Main( string [] args) { var result = from say in Enumerable...
Getting values out of XML in .NET 3.5 (LINQ to XML series part 2)
In my last post I gave a brief introduction to some of the new XML classes available in .NET 3.5. In this post I'll continue that introduction by explaining...
Introduction to LINQ to XML
Last year I wrote about the new languages features available in C# 3.0 ( Anonymous Types , Extension Methods , Automatic Properties , A start on LINQ , Object...
Inserting geometry through a .NET Application
THIS POST REFERS TO THE NOVEMBER 2007 CTP (CTP 5) OF SQL SERVER 2008 Following from my previous posts ( Getting started with Spatial Data in SQL Server 2008 ,...
What is a DAL (Part 4)
As has been mentioned previously, one of the purposes of the DAL is to shield that application from the database. That said, what happens if a DAL throws an...
What is a DAL (Part 3)
In this continuation of my series on the DAL I'm going to show the ability to create several DALs and have a Factory class instantiate the correct DAL based on...
What is a DAL?
I occasionally see posts on forums asking for help with some database problem. Then I see they've been using the the wizards in Visual Studio (which is okay...
SQL Exception because of a timeout
You think it would be easy to find information on exactly what error number a SqlException has when the command timed out. But, it isn't. MSDN , for all that...
Things I keep forgetting about FileInfo
This is going to sound like a real newbie post. But I keep forgetting this particular bit of information and I keep having to write little throw away...
The simplicity of nullable types
I just discovered nullable types. Wow! They are really simple and such a powerful feature. Just see for yourself.... If you have an int or a DateTime or any...
The Conditional attribute in .NET
One of the odd thoughts that shoot across my brain today was how does Debug.Assert() work? I mean there are not separate debug and release builds of the .NET...
A start on LINQ
I was at the Microsoft MSDN Roadshow today and I got to see some of the latest technologies being demonstrated for the first time and I'm impressed. Daniel...
Test Driven Development By Example
Introduction A lot has been written on the subject of test driven development, and especially on the idea that tests ought to be written first. This is an...
How to get a list of all subdirectories
This is an example of how to obtain a list of all subdirectories using a recursive method with the .NET Framework. public static List...
The Public Fields debate again
Back in November last year I wrote about why you should make fields in a class private. Some people still make fields public. I did concede on one argument though...
Why make fields in a class private, why not just make them public?
Encapsulation is sometimes also known as information hiding. The idea is that an object hides the details of how it works from the outside world. However, some definitions of encapsulation suggest...
SQL Injection Attacks
There is also a proportion of people responding to these questions that give advice that opens up gaping security holes...'
The Lazy NotSupportedException
I am currently building a class library that makes extensive use of abstract classes and interfaces, and like all good TDD (Test Driven Development) I am writing the tests up front...
