public ArtofKinectRecorderWindow() { InitializeComponent(); frameQueue = new WorkQueue <MotionFrame>(); frameQueue.Callback = ProcessFrame; frameQueue.MaxQueueLength = 5; InitSensor(); InitSerializer(); InitSoundCapture(); CreateViews(); lastFPSCheck = DateTime.Now; Application.Current.Exit += (s, e) => { this.CurrentFrameViewer = null; pointCloudFrameViewer.pointCloudImage.Dispose(); //pointCloudFrameViewer2.Deactivate(); //pointCloudFrameViewer2.pointCloudImage.Dispose(); if (playerSource != null) { playerSource.Dispose(); playerSource = null; } if (soundRecording != null) { soundRecording.Stop(); soundRecording.Dispose(); soundRecording = null; } if (sensorDevice != null) { sensorDevice.Dispose(); sensorDevice = null; } if (frameQueue != null) { frameQueue.Dispose(); frameQueue = null; } }; }