Blog of Rob Galanakis (@robgalanakis)

.NET

Two keys to effective multithreaded programs

In my last post, I went over a mostly lock-free producer/consumer queue that worked entirely off the ThreadPool. This covers the two most important aspects to effective multithreaded programming: avoid creating new Threads, and work lock-free where possible. Avoiding the creation of new threads is easy- you just need...

Read more

Completely async file writer

I’ve been doing more and more asynchronous programming lately.  I needed to implement a logging system recently, but wanted to use asynchronous file IO.  There was also the possibility that log calls could come in faster than they could complete, so I needed to synchronize the logging calls, marking...

Read more

Do you have your Visual Studio WinForms Designer License?

I often joke at work that you should need a license to use the Visual Studio GUI Designer.  Not because it is hard to use- quite the contrary.  Because it is so goddamn easy to make a UI, people forget that UI classes should be written like any other...

Read more

Lazy iteration, potential benefit

At this point, most people are familiar with the deferred evaluation model of LINQ, using ‘yield’ statements. Since this is new for some teams at work, there’s been a question of when is it appropriate. Deferred evaluation is of most benefit when there is some chance the entire Enumerable...

Read more

Naive Programming and Multithreading

I on almost weekly basis, I run into some example of naive programming regarding threading. Generally they have the following in common: 1- Uses Thread.Start 2- Show no understanding of CPU-vs-IO bound operations 3- Show no understanding of how a computer manages threads Take this psuedocode for some widely-used...

Read more

Exceptions vs. No Exceptions

When I moved onto the tools team, I was shocked to find out that the codebase is written not to throw or expect exceptions. I withheld judgement for a little while (because it wasn’t going to change and I have respect for the people who made the decision), but...

Read more

Generic Interfaces/Abstract Base Classes

I want to show a really useful pattern I’ve been taking advantage of recently. public interface IXElementSerializable where T : IXElementSerializable { T Deserialize(XElement element); XElement Serialize(); } public class MyType : IXElementSerializable { public MyType Deserialize(XElement element) { … } public XElement Serialize() { … } } I...

Read more

Math Libraries

.NET 3d math libraries are a bit strange. There are a few options available- arguably the best one, XNA, only works for 32 bit. If you want an x64 math library, your pickings are slim. So, after having been through a number of the public offerings available, and having...

Read more

Against Serialization with XmlSerialization

There’s a terrible monster in .NET’s closest, and its name is XmlSerialization. I love serialization to XML (or whatever your node-based text format of choice is), and I love XML in .NET and C#, but XmlSerialization is a horror. Let’s look at the requirements for XML serialization with the...

Read more

Extending LinqToXml for better XML interaction

Many tools programmers or tech artists work with XML on a daily basis.  For .NET developers, there are three ways to work with XML.  You can use XML serialization (built in or custom), the System.Xml namespace, or LinqToXml (System.Xml.Linq).  I usually advocate XML serialization (with custom serialization routines!), but...

Read more

1 2 3