We have a number of Windows Services in our infrastructure, all of which have a frequency in their configuration. Originally this frequency was in milliseconds but this is a real pain since when you set or read the configuration you are always doing the math between milliseconds and hours/minutes/seconds. Then is occurred that we could probably use a TimeSpan in the configuration to represent frequency instead of an integer of milliseconds. The .NET configuration API has a built in converter for the TimeSpan class so all you have to do is set the configuration property type to TimeSpan and your good to go!

Here is the configuration class:

public class Section : ConfigurationSection
{
    private const string FREQUENCY = "frequency";

    [ConfigurationProperty(FREQUENCY)]
    public TimeSpan Frequency
    {
        get { return (TimeSpan)this[FREQUENCY]; }
    }
}

Here is the configuration, much easier to read/set:

<company>
  <services>
    <someService frequency="00:00:30"/>
  services>
company>

And the usage:

private Common.Timers.Timer _processTimer =
        new Common.Timers.Timer(
            Configuration.Manager.Current.SomeService.Frequency.TotalMilliseconds,
            Common.Timers.Timer.TimerElapseStartMode.Immediate,
            Common.Timers.Timer.TimerElapseReentranceMode.NonReentrant);