Sorting and Grouping – organizing data with LINQ

Last week I introduced LINQ from the perspective of a C# game developer completely unfamiliar with the framework. Today I would like to continue exploration of LINQ by focussing on a particular set of its functionality: methods to arrange and organize data. In particular we will look into how we can sort and group our collections of items. Sorting with ...

Read More »

Code review challenge – The concurrent dictionary refactoring – answer

Here is the full method that we refactored: public void ReturnMemory(byte* pointer) { var memoryDataForPointer = GetMemoryDataForPointer(pointer); _freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x => { var newQueue = new ConcurrentStack<AllocatedMemoryData>(); newQueue.Push(memoryDataForPointer); return newQueue; }, (x, queue) => { queue.Push(memoryDataForPointer); return queue; }); } And here is the allocation map for this method: public unsafe void ReturnMemory(byte* pointer) { <>c__DisplayClass9_0 CS$<>8__locals0 = new <>c__DisplayClass9_0(); CS$<>8__locals0.memoryDataForPointer ...

Read More »

Code review challenge – The concurrent dictionary refactoring

In a recent code review, I had modified the following code:   _freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x => { var newQueue = new ConcurrentQueue<AllocatedMemoryData>>(); newQueue.Enqueue(memoryDataForPointer); return newQueue; }, (x, queue) => { queue.Enqueue(memoryDataForPointer); return queue; }); Into this code: var q = _freeSegments.GetOrAdd(memoryDataForPointer.SizeInBytes, size => new ConcurrentQueue<AllocatedMemoryData>()); q.Enqueue(memoryDataForPointer); Can you tell me why? Reference: Code review challenge – The concurrent dictionary refactoring from ...

Read More »

Windows applications: Icons and the Shell; names, sizes, etc.

When adding Icons to your Windows applications a few things matter. Selecting the icon resource The icon selected by the Windows Shell (for modern Windows versions usually Windows Explorer), is the one with the lowest ID. When there is no icon with an ID, it selects the icon with the lowest name. Icons in Windows can have both IDs and ...

Read More »

Hack the Remote Desktop .RDP file

Glad I found out about the string to add to a .RDP file to make it connect to the administrative console whenever your remote supports that:   connect to console:i:1 Reference: Hack the Remote Desktop .RDP file from our NCG partner Jeroen Pluimers at the The Wiert Corner blog.

Read More »

LINQ – a game development focused introduction

I was recently asked for some pointers on how to get started with LINQ – and to maybe write a post about that. Using LINQ virtually every day I have to admit that it had not occurred to me that a C# programmer may not be familiar with it. LINQ is a big topic, but this post is the first ...

Read More »

Do We Really Need Estimates?

Okay, so you’ve read anything I wrote before, you probably know by now, that I am a strong proponent of Agile methodologies. I’ve said it before, and I’ll say it again: Estimates Are Wasteful It doesn’t matter if it was a friendly debate with a manager, discussion with a client, heckling from someone in the audience of a presentation, but ...

Read More »

Did you know that Visual Studio shows deadlocked tasks?

I didn’t… And it’s not a new feature – since it existed since freaking Visual Studio 2010! Yesterday during an unrelated meeting Alon Fliess showed a bunch of us developers how Visual Studio detects deadlocks in tasks (automatically) and shows the current task status in both Parallel Tasks and Tasks debug windows (duh). I got home late but I wanted ...

Read More »

Legacy Code to Testable Code #11: More Static Constructors

Where we last left off, we discussed how to dismantle the static constructor (or initializer) booby traps. And I promised you an example. I’ll do that in C#, but the operations apply to any language that uses these constructs. Before I do that I’ll remind you main problem here: Static initializers are used as short cuts for initialization of a ...

Read More »

Articles on TrackJS, Microservices, PowerShell, .NET CLI

In the last edition for 2015, there are 11 articles on technology, news, open source, community on the fantastic and ever evolving technology world. Happy holidays! Exploring the new .NET (Scott Hanselman) I’ve never much like the whole “dnvm” and “dnu” and “dnx” command line stuff in the new ASP.NET 5 beta bits. There’s reasons for each to exist and they ...

Read More »