skip to Main Content

Finds of the Week – June 17, 2008

.NET, C#

General Development

Software, Tools, etc.

Gaming

Something Different

Finds of the Week – June 9, 2008

.NET/C#

  • Microsoft project code named “Velocity” is a distributed in-memory caching platform that provides .NET applications with high-speed access, scaling, and high availability to application data. Download the Community Preview here.
  • Danny Simmons enumerated various reasons for using Entity Framework.
  • If your netMsmq WCF service shows signs of a handles leak, you may want to make sure you have .NET Framework 3.0 Service Pack 1 installed.
  • Bryan wrote a timely article on TDD Tips: Test Naming Conventions & Guidelines.
  • Microsoft announced the release of Microsoft Source Analysis for C#.
    “Source Analysis is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while Source Analysis analyzes the source code directly. For this reason, Code Analysis focuses more on the design of the code, while Source Analysis focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.”

General Programming

Tools

  • The Query command line utility displays active Terminal Service/Remote Desktop sessions, among other things. This replaces the qwinsta utility.

Something Different

Finds of the Week – May 31, 2008

Programming

.NET/C#

Software and Tools

  • Google Maps Street View is in Richmond.

    Google Street View Richmond Virginia Goo

    It looks like the Street View images were taken around September 2007 because according to IMDB, the movie Game Plan was playing in the US starting 9/23/2007:

    Google Street View Richmond

  • Google Maps adds user-created photos, videos, maps. Via CNET.

    Google Maps Goog

Something Different

Splitting a Generic List<T> into Multiple Chunks

Greetings visitor from the year 2020! You can get the latest code for this from my Github repo here. Thanks for visiting.

“Chunking” is the technique used to break large amount of work into smaller and manageable parts. Here are a few reasons I can think of why you want to chunk, especially in a batch process where you have to process large number of items:

  • Manage/minimize peak memory requirement.
  • During failures, the entire process can resume at the last failure point, instead of all the way from the beginning.
  • Take advantage of multiple processors/cores (by having multiple threads, each processing a small chunk).

Here’s a helper method to quickly split a List<T> into chunks:

/// <summary>
/// Splits a <see cref="List{T}"/> into multiple chunks.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list">The list to be chunked.</param>
/// <param name="chunkSize">The size of each chunk.</param>
/// <returns>A list of chunks.</returns>
public static List<List<T>> SplitIntoChunks<T>(List<T> list, int chunkSize)
{
    if (chunkSize <= 0)
    {
        throw new ArgumentException("chunkSize must be greater than 0.");
    }

    List<List<T>> retVal = new List<List<T>>();
    int index = 0;
    while (index < list.Count)
    {
        int count = list.Count - index > chunkSize ? chunkSize : list.Count - index;
        retVal.Add(list.GetRange(index, count));

        index += chunkSize;
    }

    return retVal;
}
 

If you want to be more efficient at the cost of readability, the second version below moves the items from the big list into the small chunks, so both types of lists will not need to be in memory at once:

 

/// <summary>
/// Break a <see cref="List{T}"/> into multiple chunks. The <paramref name="list="/> is cleared out and the items are moved
/// into the returned chunks.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list">The list to be chunked.</param>
/// <param name="chunkSize">The size of each chunk.</param>
/// <returns>A list of chunks.</returns>
public static List<List<T>> BreakIntoChunks<T>(List<T> list, int chunkSize)
{
    if (chunkSize <= 0)
    {
        throw new ArgumentException("chunkSize must be greater than 0.");
    }

    List<List<T>> retVal = new List<List<T>>();

    while (list.Count > 0)
    {
        int count = list.Count > chunkSize ? chunkSize : list.Count;
        retVal.Add(list.GetRange(0, count));
        list.RemoveRange(0, count);
    }

    return retVal;
}

Finds of the Week – April 6, 2008

Programming

.NET/C#

Windows Mobile/Pocket PC

Gaming

Something a Little Different

Finds of the Week – March 30, 2008

Programming

.NET/C#

PowerShell

Finds of the Week – March 23, 2008

Programming

C#

Something a Little Different

Finds of The Week – March 16, 2008

Programming

C#.NET

Software & Tools

Gadgets

  • I got myself a ThinkPad X60 Tablet PC last week, so naturally I’m writing this article on it :-). The Tablet PC Team Blog is a good starting location to look for Tablet PC tips. The combination of a Tablet PC and Microsoft OneNote is very nice. I am surprised at how good the text recognition engine engine in Windows Vista is.

     Tablet PC Writing Pad

Misc

Something a Little Different

Back To Top