title: Monitor changes to settings in app.config
body: <p>When I use typesafe application settings, I have something like this in my app.exe.config file:</p>
  
  <pre><code>&lt;setting name="IntervalTimeout" serializeAs="String"&gt;
      &lt;value&gt;10&lt;/value&gt;
  &lt;/setting&gt;
  </code></pre>
  
  <p>The Settings.Designer.vb does something like this:</p>
  
  <pre><code>&lt;Global.System.Configuration.ApplicationScopedSettingAttribute(),  _
   Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
   Global.System.Configuration.DefaultSettingValueAttribute("10")&gt;  _
  Public ReadOnly Property IntervalTimeout() As Integer
      Get
          Return CType(Me("IntervalTimeout"),Integer)
      End Get
  End Property
  </code></pre>
  
  <p>And I can access the setting with something like this:</p>
  
  <p>Settings.IntervalTimeout</p>
  
  <p>What is the best practice for monitoring changes to this setting from the outside. I.e. the setting is used by an application that is running as a service and when somebody opens the corresponsing config file and changes the IntervalTimeout to let's say 30, the service application gets notified and does whatever I tell it to do to reconfigure itself.</p>
  
  <p>Usually, I would have used something like this during initialization:</p>
  
  <pre><code>AddHandler Settings.PropertyChanged, New PropertyChangedEventHandler(AddressOf Settings_PropertyChanged)
  </code></pre>
  
  <p>And then implement an Eventhandler that checks the name of the property that has changed and reacts appropriately.</p>
  
  <p>However, the PropertyChanged event only gets fired when the Set method is called on a property, not when somebody changes the data directly within the file. Of course this would have been heaven, but understandable that this is not the way it works. ;-)</p>
  
  <p>Most probably, I'd implement a filesystemwatcher to monitor changes to the file and then reload the configuration, find out what changed and then do whatever is necessary to reflect those changes.</p>
  
  <p>Does anyone know a better way? Or even a supported one?</p>