private void CloseVideoSource()
{
// set busy cursor
this.Cursor = Cursors.WaitCursor;
// stop current video source
videoSourcePlayer1.SignalToStop();
// wait 2 seconds until camera stops
for (int i = 0; (i < 50) && (videoSourcePlayer1.IsRunning); i++)
{
Thread.Sleep(100);
}
if (videoSourcePlayer1.IsRunning)
{
videoSourcePlayer1.Stop();
}
// stop timers
timer.Stop();
alarmTimer.Stop();
motionHistory.Clear();
// reset motion detector
if (detector != null)
{
detector.Reset();
}
videoSourcePlayer1.BorderColor = Color.Black;
this.Cursor = Cursors.Default;
}