I started creating a WinForms application for the Lync SDK. I want the client subscribing to some events.
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();
}
}
Where do I have to subscribe the client.StateChanged
event?
client.StateChanged += Client_StateChanged;
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?