private void Camera_ConnectionLost(object sender, EventArgs e) { CameraDisconnected?.Invoke(this, EventArgs.Empty); ConnectedCamera = null; StartPortsMonitoring(); }
private void Monitor(object state) { var availableCameras = CameraFinder.Enumerate(); if (availableCameras.Any() && ConnectedCamera == null) { try { var camera = new Camera(); camera.Open(); ConnectedCamera = new CameraBasler(camera); ConnectedCamera.SetDefaultSettings(); ConnectedCamera.Camera.ConnectionLost += Camera_ConnectionLost; OnCameraConnected(); timer.Dispose(); } catch (Exception) { OnCameraFailed("The camera is in use by another application. Close the other application to start recording"); } } else { OnCameraFailed("Camera not found"); } }