<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Antony Male</title>
    <link>http://antonymale.co.uk/</link>
    <description>Recent content on Antony Male</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Fri, 17 Feb 2017 17:40:08 +0100</lastBuildDate>
    
	<atom:link href="http://antonymale.co.uk/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Installing .NET using Inno Setup</title>
      <link>http://antonymale.co.uk/installing-dotnet-using-inno-setup.html</link>
      <pubDate>Fri, 17 Feb 2017 17:40:08 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/installing-dotnet-using-inno-setup.html</guid>
      <description>&lt;p&gt;There are many blog posts online telling you how to install the .NET Framework using &lt;a href=&#34;http://www.jrsoftware.org/isinfo.php&#34;&gt;Inno Setup&lt;/a&gt;.
Most of them work in most cases, but they fail to properly handle restarting the machine if the .NET Framework installer needs to restart, or handle errors encountered by the .NET Framework installer.
If you put a bit more effort in (and learn a bit of Pascal!), you can write something more robust.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Monotonic timestamps in C#</title>
      <link>http://antonymale.co.uk/monotonic-timestamps-in-csharp.html</link>
      <pubDate>Fri, 17 Feb 2017 15:50:50 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/monotonic-timestamps-in-csharp.html</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve ever written code which compares two &lt;code&gt;DateTimes&lt;/code&gt;, you might be living on borrowed time.
Most people assume that time ticks forwards at a rate of one second per second, and this assumption pervades a lot of our programming as well.
However this isn&amp;rsquo;t always the case: the user changing their clock, or leap seconds, can cause time to jump backwards and forwards, invalidating your calculations.
Even recently this &lt;a href=&#34;https://blog.cloudflare.com/how-and-why-the-leap-second-affected-cloudflare-dns/&#34;&gt;caused serious issues for CloudFlare&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The solution is simple: use a monotonic time source: one that is independent of the system time, and always ticks forward at a rate of one second per second.
Unfortunately .NET doesn&amp;rsquo;t expose such a time source directly.
Here&amp;rsquo;s an easy way to make one.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>How to tell Visual Studio where to find design-time resources for WPF</title>
      <link>http://antonymale.co.uk/design-time-resources-in-wpf.html</link>
      <pubDate>Sat, 13 Aug 2016 12:48:00 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/design-time-resources-in-wpf.html</guid>
      <description>&lt;p&gt;When you&amp;rsquo;re writing XAML using the Visual Studio designer, you&amp;rsquo;ll sometimes find that it&amp;rsquo;s unable to locate resources that are stored in a ResourceDictionary (and referenced using &lt;code&gt;{StaticResource}&lt;/code&gt;).
This is a particular problem if you&amp;rsquo;re working on a class library project (rather than a WPF application), as it often won&amp;rsquo;t be able to find the correct &lt;code&gt;Application&lt;/code&gt; to start, and so won&amp;rsquo;t load its resources.
It can also happen if you&amp;rsquo;re loading ResourceDictionaries dynamically.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Implementing Equals and GetHashCode in C#</title>
      <link>http://antonymale.co.uk/implementing-equals-and-gethashcode-in-csharp.html</link>
      <pubDate>Thu, 04 Aug 2016 20:45:20 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/implementing-equals-and-gethashcode-in-csharp.html</guid>
      <description>&lt;h2 id=&#34;equals-and-gethashcode&#34;&gt;Equals and GetHashCode&lt;/h2&gt;

&lt;p&gt;If you want to compare your objects for equality, you&amp;rsquo;re going to have to implement &lt;code&gt;Equals&lt;/code&gt; and &lt;code&gt;GetHashCode&lt;/code&gt;.
There are plenty examples around of how to do this, but they tend to contradict each other.
This is the pattern that I follow.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Internationalization in WPF</title>
      <link>http://antonymale.co.uk/internationalization-in-wpf.html</link>
      <pubDate>Mon, 08 Feb 2016 00:00:00 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/internationalization-in-wpf.html</guid>
      <description>Introduction Everyone has their own opinion on how a WPF application should be internationalized. People have tried referencing resources directly using {x:Static}, using tools to parse the compiled XAML for strings, and everything in between. Each approach has advantages and disadvantages, but it&amp;rsquo;s hard to figure out what&amp;rsquo;s best for you.
In my case, I couldn&amp;rsquo;t find any existing solutions which fitted my needs well, so I did what I normally end up doing and wrote my own.</description>
    </item>
    
    <item>
      <title>Don&#39;t create too many Icons</title>
      <link>http://antonymale.co.uk/dont-create-too-many-icons.html</link>
      <pubDate>Sat, 06 Feb 2016 19:22:26 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/dont-create-too-many-icons.html</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s a fun little gotcha.&lt;/p&gt;

&lt;p&gt;I was creating a list of files, displayed to the user.
Alongside each file I was displaying the icon associated with the file type; fetching it using &lt;a href=&#34;http://codesdirectory.blogspot.co.uk/2013/01/displaying-system-icon-in-c-wpf.html&#34;&gt;&lt;code&gt;SHGetFileInfo&lt;/code&gt;&lt;/a&gt;, storing the &lt;code&gt;Icon&lt;/code&gt; instance in the ViewModel for each file entry, then converting that to a &lt;code&gt;BitmapSource&lt;/code&gt; using a converter on the binding.
Should be fine, right?&lt;/p&gt;

&lt;p&gt;And it was fine, until a user tried to list a few thousand files.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Per-solution NuGet package sources</title>
      <link>http://antonymale.co.uk/per-solution-nuget-package-sources.html</link>
      <pubDate>Sat, 06 Feb 2016 18:32:26 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/per-solution-nuget-package-sources.html</guid>
      <description>&lt;p&gt;Normally, if you want to add a custom NuGet package source, you do this from within Visual Studio: &lt;code&gt;Tools -&amp;gt; Options -&amp;gt; NuGet Package Manager -&amp;gt; Sources&lt;/code&gt;.
However, this means that everyone who wants to build your project has to have those same custom package sources configured, which is annoying.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>A simple approach to custom configuration sections in C#</title>
      <link>http://antonymale.co.uk/custom-configuration-sections-in-csharp.html</link>
      <pubDate>Sun, 24 Jan 2016 14:07:28 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/custom-configuration-sections-in-csharp.html</guid>
      <description>&lt;p&gt;&lt;code&gt;App.config&lt;/code&gt; is a great convenient place to store the sorts of magic values that your application needs in order to run, but which you &lt;em&gt;might&lt;/em&gt; want to change after installing, without recompiling.
Using the built-in &lt;code&gt;Properties\Settings.settings&lt;/code&gt; UI, and then accessing those with &lt;code&gt;Properties.Settings.Default&lt;/code&gt;, is a fine way of putting custom data in &lt;code&gt;App.config&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>How to call ICostManager::GetCost from C#</title>
      <link>http://antonymale.co.uk/calling-icostmanager-getcost-from-csharp.html</link>
      <pubDate>Sun, 24 Jan 2016 13:17:26 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/calling-icostmanager-getcost-from-csharp.html</guid>
      <description>&lt;p&gt;Windows 8 introduced the concept of a metered connection.
A metered connection indicates that the user is being charged for data transfer on that network, and so you might want to limit how much you transfer.
WinRT provides classes in the &lt;a href=&#34;https://msdn.microsoft.com/en-us/library/windows.networking.connectivity.aspx&#34;&gt;&lt;code&gt;Windows.Networking.Connectivity&lt;/code&gt;&lt;/a&gt; namespace to determine whether or not a given connection is metered (and much more besides), but there&amp;rsquo;s nothing directly available in traditional .NET applications.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Why use &#34;async void&#34; in C#</title>
      <link>http://antonymale.co.uk/why-use-async-void-in-csharp.html</link>
      <pubDate>Sun, 04 Oct 2015 12:53:57 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/why-use-async-void-in-csharp.html</guid>
      <description>&lt;p&gt;Beginners are often told to avoid using &lt;code&gt;async void&lt;/code&gt; in C#, and with good reason: 90% of the time, they actually wanted &lt;code&gt;async Task&lt;/code&gt;.
They&amp;rsquo;re told to only use &lt;code&gt;async void&lt;/code&gt; in event handlers, where a &lt;code&gt;Task&lt;/code&gt; can&amp;rsquo;t be returned.&lt;/p&gt;

&lt;p&gt;However, &lt;code&gt;async void&lt;/code&gt; does have some other uses.

Take, for example, these two code snippets:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Binding to a PasswordBox&#39;s Password property in WPF</title>
      <link>http://antonymale.co.uk/binding-to-a-passwordbox-password-in-wpf.html</link>
      <pubDate>Fri, 07 Aug 2015 09:40:19 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/binding-to-a-passwordbox-password-in-wpf.html</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve ever tried to write XAML which looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;PasswordBox Password=&amp;quot;{Binding Password}&amp;quot;/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You&amp;rsquo;ll have quickly found out that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A &amp;lsquo;Binding&amp;rsquo; cannot be set on the &amp;lsquo;Password&amp;rsquo; property of type &amp;lsquo;PasswordBox&amp;rsquo;. A &amp;lsquo;Binding&amp;rsquo; can only be set on a DependencyProperty of a DependencyObject.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Cancelling tasks in C#</title>
      <link>http://antonymale.co.uk/cancelling-tasks-in-csharp.html</link>
      <pubDate>Thu, 06 Aug 2015 20:14:29 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/cancelling-tasks-in-csharp.html</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s something I see from time to time: people new to Tasks in C# don&amp;rsquo;t know how to cancel them.
Let&amp;rsquo;s look at some common misconceptions, and what you should actually do.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Converting Endianness in C#</title>
      <link>http://antonymale.co.uk/converting-endianness-in-csharp.html</link>
      <pubDate>Tue, 28 Jul 2015 12:56:05 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/converting-endianness-in-csharp.html</guid>
      <description>&lt;p&gt;A while back, I found myself wanting to convert the endianness of an integer or floating-point number in C# (for a binary-to-C#-class conversion library that&amp;rsquo;s still waiting to be finished).
Since then, I&amp;rsquo;ve had a few people ask the same question (normally because they&amp;rsquo;re reading or writing some low-level format using a &lt;code&gt;BinaryReader&lt;/code&gt; or &lt;code&gt;BinaryWriter&lt;/code&gt;), so thought I&amp;rsquo;d write up what I found.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Generating PuTTY key files from C#</title>
      <link>http://antonymale.co.uk/generating-putty-key-files.html</link>
      <pubDate>Mon, 20 Jul 2015 12:04:58 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/generating-putty-key-files.html</guid>
      <description>&lt;p&gt;A while back, I had a project which needed to be able to write &lt;a href=&#34;http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe&#34;&gt;PuTTY&lt;/a&gt; private key files. (For context, it was a tool that was able to spin up Amazon EC2 instances, then launch PuTTY to connect to them, so it needed to turn an RSA key into a private key which could be given to PuTTY). Now, there&amp;rsquo;s a tool called &lt;a href=&#34;http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe&#34;&gt;PuTTYgen&lt;/a&gt; which is able to do this, but I needed I needed to be able to do it programmatically.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Atomic File Writes on Windows</title>
      <link>http://antonymale.co.uk/windows-atomic-file-writes.html</link>
      <pubDate>Fri, 17 Jul 2015 21:25:36 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/windows-atomic-file-writes.html</guid>
      <description>&lt;p&gt;The other day a few people &lt;a href=&#34;https://github.com/canton7/SyncTrayzor/issues/120&#34;&gt;reported&lt;/a&gt; an &lt;a href=&#34;https://github.com/canton7/SyncTrayzor/issues/123&#34;&gt;issue&lt;/a&gt; with one of my open source applications, in that a forced shutdown could leave the config file full of zeros. The culprit was almost certainly the fact that the application would try to write to its config file just after the main window was closed (in order to save the window&amp;rsquo;s size and location), but that write was being cut off after the file had been zero&amp;rsquo;d, but before some interal cache had been flushed to disk, resulting in lots of NULLs.&lt;/p&gt;

&lt;p&gt;So, atomic file writes are in order. Easy on Linux, less easy on Windows. Where to start?&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>New Website!</title>
      <link>http://antonymale.co.uk/new-website.html</link>
      <pubDate>Fri, 17 Jul 2015 21:06:29 +0100</pubDate>
      
      <guid>http://antonymale.co.uk/new-website.html</guid>
      <description>So, I&amp;rsquo;ve finally got a new website. It&amp;rsquo;s been a long time coming, but hopefully it&amp;rsquo;s worth it.
This site uses hugo, which is a lovely little static site generator written in Go (which has the advantage of being a single drop-and-run-anywhere executable). The theme&amp;rsquo;s been adaped from purehugo by Dragos Plesca.
The intention is that I&amp;rsquo;ll record useful stuff I find and figure out on here, relating to whatever programming langauge I&amp;rsquo;m using at the time.</description>
    </item>
    
    <item>
      <title>About this Website</title>
      <link>http://antonymale.co.uk/about/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/about/</guid>
      <description>About this Website About Me Hi, I&amp;rsquo;m Antony Male, and I&amp;rsquo;m a software engineer.
This website is a place for me to record useful bits of information / snippets of code / etc that I put together or find online. This is mostly so that I don&amp;rsquo;t forget them and so that I can link other people to them, but who knows, maybe Google will direct others to them as well.</description>
    </item>
    
    <item>
      <title>Useful Links</title>
      <link>http://antonymale.co.uk/links/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>http://antonymale.co.uk/links/</guid>
      <description>Useful Links A collection of useful links, put in one place.
C# Articles  Threading in C# (Albahari) &amp;ndash; In-depth threading text It&amp;rsquo;s All About the SynchronizationContext &amp;ndash; Stephen Cleary describes the SynchronizationContext and how it&amp;rsquo;s used Can I skip the lock when reading an integer? (part 2) &amp;ndash; Eric Lippert covers locking subtleties When everything you know is wrong (part 2, related) &amp;ndash; Eric Lippert dispels myths about .</description>
    </item>
    
  </channel>
</rss>