private void AnaForm_FormClosed(object sender, FormClosedEventArgs e) { if (webcam != null) { webcam.Stop(); } if (scan0 != IntPtr.Zero) { Marshal.FreeCoTaskMem(scan0); } scan0 = IntPtr.Zero; if (webcam != null) { webcam.Disconnect(); } timer.Enabled = false; }