private void exitToolStripMenuItem_Click(object sender, EventArgs e) { CloseVideoSource(); if (ShimmerDevice1 != null) { if (ShimmerDevice1.GetState() == (int)Shimmer.SHIMMER_STATE_STREAMING) { ShimmerDevice1.StopStreaming(); } ShimmerDevice1.Disconnect(); } if (ShimmerDevice2 != null) { if (ShimmerDevice2.GetState() == (int)Shimmer.SHIMMER_STATE_STREAMING) { ShimmerDevice2.StopStreaming(); } ShimmerDevice2.Disconnect(); } try { if (_writeToFileShimmer1 != null) { _writeToFileShimmer1.CloseFile(); } if (_writeToFileShimmer2 != null) { _writeToFileShimmer2.CloseFile(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Control.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning); throw; } Application.Exit(); }
/// <summary> /// Disconnect device from system. /// TODO: figure out why it's crashing on closing connection. Might be part of the "StopStreaming" function /// </summary> public void Disconnect() { if (ShimmerDevice != null) { if (ShimmerDevice.GetState() == (int)Shimmer.SHIMMER_STATE_STREAMING) { if (ShimmerDevice.GetFirmwareIdentifier() == 3) { } else { ShimmerDevice.StopStreaming(); } } } DeviceConnected = false; ShimmerDevice.Disconnect(); //if (streamingActuallyOccurred()) { // handleLogging(); } }