title: Fire event when a property or variable changes value
body: <p>I want to add more functionality to a project I have that makes use a number of classes packaged in the NET Framework. These same classes provide a number of properties which can be quite useful adapting the functionality of my project, however one thing that these classes lack is Events.</p>
  
  <p>If each property had a appropriate event that would fire whenever the value of such property changed, I could then assign a event handler that would act based on those properties value.</p>
  
  <p>I made a sample case bellow to illustrate my goal in the most simpler way I could think off.</p>
  
  <blockquote>
    <p><strong>Sample case:</strong> </p>
    
    <p>The <code>System.Net.Sockets.Socket</code> class (<a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx" rel="nofollow">Socket on MSDN Docs</a>) has a property
    named <code>Connected</code> that basically returns true if the socket is
    connected to a specified end point otherwise returns false.</p>
    
    <p>What I would like to accomplish is simple. I would like to keep this
    property under "watch" and when the value of it changes, fire a event.</p>
  </blockquote>
  
  <p>Doing that to one of my own classes it would be simple although a bit tiresome using the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.propertychanged.aspx" rel="nofollow">INotifyPropertyChanged interface</a>, simply because always that my code changed the value of the property I would have to fire the event manually. Unfortunately, to best of my knowledge, not even this kind of procedure can be applied to the existing <code>Socket</code> class distributed within NET Framework.</p>
  
  <p>Well, this question is becoming quite extensive, sorry, but I hope it gave an insight to my goal.</p>
  
  <p>Now simply putting it, I want to watch the <code>Connected</code> property of the <code>Socket</code> class and when the value of it changes, fire an event. And if it would be possible to also use such approach to watch variables as well properties, it would be awesome, not just for me, but for everyone who stumbles across this question on SO.</p>
  
  <p>A simple and lightweight approach is preferred of course, but most of all, I want to understand how it can be done, so in the future I can apply it in mass scale to other classes.</p>
  
  <p>I realize I'm asking a lot. Many thanks.</p>
  
  <p><em>Any questions just ask.</em></p>