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 unnecessary trips to the server, it doesn’t prevent invalid data getting to the  server if JavaScript is turned off or if a user crafts a specific HTTP request […]

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 some validation to the inputs. At the moment, since there is no validation, the use can just submit the input as it is with the […]

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 number of values from the user that is then used to calculate the calorific intake. The original calculation can be found here here: How many […]

Tip of the day #22: 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> GetSubdirectories(DirectoryInfo directory) { // Set up the result of the method.List<DirectoryInfo> result = new List<DirectoryInfo>(); // Attempt to get a list of immediate child directories from the directory // that was […]

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 error throws an exception. In the first example, only one task throws an exception. Although from the output you can see that more tasks were expected […]

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 object graph without dependencies on other objects outside its own graph. Each iteration of the Parallel.ForEach statement operates on only one item in the List named initialObjectGraph. The operations […]

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 tasks in a real system) which is implemented by MainTask and then waits for that task to complete. The MainTask then launches many independent tasks (impelemnted as […]

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 Library takes care of the actual scheduling, degree of parallelism etc. Parallel.Invoke itself blocks until all the tasks have completed. In this example there are two tasks that […]

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 in the System.Collections.Concurrent namespace In this example, the ConcurrentBag is populated in task that is running in the background. After a brief pause in order to allow the background task […]

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 ConcurrentDictionary. Code Example class Program { private static ConcurrentDictionary<string, int> wordCounts = new ConcurrentDictionary<string, int>(); static void Main(string[] args) { string[] lines = File.ReadAllLines("grimms-fairy-tales.txt"); Parallel.ForEach(lines, […]