title: C# Lync SDK - LyncClient subscribe to events
body: <p>I started creating a WinForms application for the Lync SDK. I want the client subscribing to some events.</p>
  
  <pre><code>public partial class FrmMain : Form
  {
          public FrmMain()
          {
              InitializeComponent();
              client = new Client(this);
          }
  }
  
  
  
      internal class Client
      {
          public Client(FrmMain frm)
          {
              this.frm = frm;
          }
  
          private FrmMain frm;
  
          public LyncClient Instance
          {
              get
              {
                  LyncClient client = null;
  
                  try
                  {
                      client = LyncClient.GetClient();
                  }
                  catch (ClientNotFoundException)
                  {
                  }
  
                  return client;
              }
          }
  
          private void Client_StateChanged(Object source, ClientStateChangedEventArgs e)
          {
              frm.UpdateSignedInState();
          }
  }
  </code></pre>
  
  <p>Where do I have to subscribe the <code>client.StateChanged</code> event?</p>
  
  <p><code>client.StateChanged += Client_StateChanged;</code></p>
  
  <p>When closing my Lync client or disconnecting I would loose the current instance so where would I have to subscribe the event that it will always trigger on state changes?</p>