private void MainForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
//stop the video preview before closing
ics.StopPreview();
//if we are conneected to the central server , logout
if (ics.IsConnectedToCentralServer)
{
ics.Logout();
//give it some time to logout
System.Threading.Thread.Sleep(2000);
e.Cancel = false;
}
}